Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Ktor's request to be executed within a try-catch block #215

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Change Ktor's request to be executed within a try-catch block #215

merged 1 commit into from
Nov 13, 2023

Conversation

chandroidx
Copy link
Contributor

馃幆 Goal

#214 Difference Exception Handling between Ktor and Retrofit

馃洜 Implementation details

Change Ktor's request to be executed within a try-catch block

鉁嶏笍 Explain examples

public suspend inline fun <reified T> HttpClient.getApiResponse(
  builder: HttpRequestBuilder,
): ApiResponse<T> {
  builder.method = HttpMethod.Get
  val response = request(builder)
  return apiResponseOf { response }
}

Changed To

public suspend inline fun <reified T> HttpClient.getApiResponse(
  builder: HttpRequestBuilder,
): ApiResponse<T> {
  builder.method = HttpMethod.Get
  return apiResponseOf { request(builder) }
}

So, Performing 'request' handled within the try-catch block inside 'apiResponseOf'

Applied spotless and apiDump 馃槅

Copy link
Owner

@skydoves skydoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Thanks for your contribution!

@skydoves skydoves merged commit e2cdd24 into skydoves:main Nov 13, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants