-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More useful error messages, print server response
- Loading branch information
Showing
2 changed files
with
82 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
syncs-kserver/src/main/java/eu/darken/octi/syncs/kserver/core/KServerHttpException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package eu.darken.octi.syncs.kserver.core | ||
|
||
import android.content.Context | ||
import eu.darken.octi.common.error.HasLocalizedError | ||
import eu.darken.octi.common.error.LocalizedError | ||
import retrofit2.HttpException | ||
|
||
class KServerHttpException( | ||
override val cause: HttpException, | ||
) : Exception(), HasLocalizedError { | ||
|
||
private var errorMessage: String = cause.response()?.errorBody()?.string() ?: cause.toString() | ||
|
||
override fun getLocalizedError(context: Context): LocalizedError = LocalizedError( | ||
throwable = this, | ||
label = cause.message(), | ||
description = errorMessage, | ||
) | ||
} |