File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/data/widgets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,21 +24,19 @@ class NewsService @Inject constructor(
2424
2525 override suspend fun fetchData (): Result <List <ArticleDTO >> = runCatching {
2626 get<List <ArticleDTO >>(Env .newsBaseUrl + " /articles" ).take(10 )
27- }.onFailure {
28- Logger .warn(e = it, msg = " Failed to fetch news" , context = TAG )
2927 }
3028
31- // Future services can be added here
3229 private suspend inline fun <reified T > get (url : String ): T {
3330 val response: HttpResponse = client.get(url)
34- Logger .debug (" Http call: $response " )
31+ Logger .verbose (" Http call: $response " , context = TAG )
3532 return when (response.status.isSuccess()) {
3633 true -> {
3734 val responseBody = runCatching { response.body<T >() }.getOrElse {
3835 throw NewsError .InvalidResponse (it.message.orEmpty())
3936 }
4037 responseBody
4138 }
39+
4240 else -> throw NewsError .InvalidResponse (response.status.description)
4341 }
4442 }
You can’t perform that action at this time.
0 commit comments