google / google/ground-android
[Code health] Create custom try/catch wrapper`
Open
type: code health
- Dominant language
- Kotlin
- Stars
- 293
- Forks
- 149
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 42
Description
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:
```kt
runCatching {
// do stuff
}.onFailureLogAndReturn("message", defaultValue)
```
Or if there's no return value:
```kt
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?
Contributor guide
Assessment
This issue has not been assessed yet.