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

[Code health] Create custom try/catch wrapper` #2891

Open
gino-m opened this issue Dec 2, 2024 · 0 comments
Open

[Code health] Create custom try/catch wrapper` #2891

gino-m opened this issue Dec 2, 2024 · 0 comments
Labels
type: code health Improvements to readability or robustness of codebase

Comments

@gino-m
Copy link
Collaborator

gino-m commented Dec 2, 2024

There are a few dozen cases where we try-catch exceptions, logging an error or debug message and returning a default value. Alternatively, we could use runCatching {}.onFailure(..) with a custom extensions on Result, like:

runCatching {
  // do stuff
}.onFailureLogAndReturn("message", defaultValue)

Or if there's no return value:

runCatching {
  // do stuff
}.onFailureLog("message")

log could log a DEBUG or ERROR Timber message depending on whether the error was a network exception or other "expected" exception.

@shobhitagarwal1612 Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: code health Improvements to readability or robustness of codebase
Projects
Status: No status
Development

No branches or pull requests

1 participant