File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,9 +147,9 @@ fun updateState(action: Action) {
147147``` kotlin
148148suspend fun getData (): Result <Data > = withContext(Dispatchers .IO ) {
149149 runCatching {
150- Result .success( apiService.fetchData() )
151- }.onFailure { e ->
152- Logger .error(" Failed" , e = e , context = TAG )
150+ apiService.fetchData()
151+ }.onFailure {
152+ Logger .error(" Failed" , it , context = TAG )
153153 }
154154}
155155```
@@ -176,6 +176,7 @@ suspend fun getData(): Result<Data> = withContext(Dispatchers.IO) {
176176- ALWAYS acknowledge datastore async operations run synchronously in a suspend context
177177- NEVER use ` runBlocking ` in suspend functions
178178- ALWAYS pass the TAG as context to ` Logger ` calls, e.g. ` Logger.debug("message", context = TAG) `
179+ - NEVER add ` e = ` named parameter to Logger calls
179180- ALWAYS log errors at the final handling layer where the error is acted upon, not in intermediate layers that just propagate it
180181- ALWAYS use the Result API instead of try-catch
181182- NEVER wrap methods returning ` Result<T> ` in try-catch
You can’t perform that action at this time.
0 commit comments