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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): catch errors #311

Merged
merged 1 commit into from
Oct 18, 2024
Merged

fix(api): catch errors #311

merged 1 commit into from
Oct 18, 2024

Conversation

kyrie25
Copy link
Contributor

@kyrie25 kyrie25 commented Oct 18, 2024

As title

@dead8309
Copy link
Owner

We already have a logger for HttpClient here

install(Logging) {
level = LogLevel.HEADERS
sanitizeHeader { header -> header == HttpHeaders.Authorization }
logger = object : Logger {
override fun log(message: String) {
kLogger.d("Ktor", message)
}
}
}

@kyrie25
Copy link
Contributor Author

kyrie25 commented Oct 18, 2024

We already have a logger for HttpClient here

install(Logging) {
level = LogLevel.HEADERS
sanitizeHeader { header -> header == HttpHeaders.Authorization }
logger = object : Logger {
override fun log(message: String) {
kLogger.d("Ktor", message)
}
}
}

It logs but will still throw errors and will perpetually crash the app as service tries to restart
Screenshot_2024-10-17-19-10-16-972_com.my.kizzy.jpg

This is reproducible if you set timeout duration to 1 to emulate timeout requests

@dead8309
Copy link
Owner

you can handle errors but don't inject/use logger there, maybe tweak the HttpClient's logger settings to include more information

@kyrie25
Copy link
Contributor Author

kyrie25 commented Oct 18, 2024

you can handle errors but don't inject/use logger there, maybe tweak the HttpClient's logger settings to include more information

Should be done, service would only catch errors now

@kyrie25 kyrie25 changed the title fix(api): catch and log errors fix(api): catch errors Oct 18, 2024
@dead8309 dead8309 merged commit cd5e2e7 into dead8309:master Oct 18, 2024
1 check passed
@kyrie25 kyrie25 deleted the api-catch-error branch October 18, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants