title: Handle no internet connection error of retrofit 2.6 with kotlin coroutines
body: <p>I'm using retrofit 2.6 with kotlin coroutines to make API call without block the UI thread, I got it work but the app crashes when I switch off the internet connection. The logcat error is: E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1</p>
  
  <p>Here is my code:</p>
  
  <pre><code>private fun handleIntent(slug: String) {
      val service = UtilityMethods.migrationTimeService()
  
      UtilityMethods.showView(loading_view)
      UtilityMethods.hideView(network_error_msg)
  
      CoroutineScope(Dispatchers.IO).launch {
          val res = service.getPostBySlug(slug)
  
              try {
                  withContext(Dispatchers.Main) {
  
                      //Do something with response e.g show to the UI.
                      val post = res.body()!!.first()
  
                      UtilityMethods.hideView(loading_view)
  
                      val title = post.title?.rendered
                      val content = post.content?.rendered
                      val imageUrl = post.jetPackFeaturedMediaUrl
  
                      title_txtView.text = if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.N)
                          Html.fromHtml(title, Html.FROM_HTML_MODE_COMPACT).toString()
                      else
                          Html.fromHtml(title).toString()
  
                      content_txtView.loadData(content.toString(), "text/html", "UTF-8")
  
                      Picasso.get().load(imageUrl).fit().centerCrop().into(thumbnail_imgview)
                  }
  
              } catch (e: HttpException) {
                  UtilityMethods.showView(network_error_msg)
              } catch (e: Throwable) {
                  Toast.makeText(this@PostContentActivity, "Ooops: Something else went wrong", Toast.LENGTH_LONG)
              }
      }
  }
  </code></pre>