forked from github/szkolny
[Errors] Add reporting the error ID.
This commit is contained in:
parent
62ae3c4c4b
commit
344da53888
@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.request.ErrorReportRequest
|
||||
import pl.szczodrzynski.edziennik.stackTraceString
|
||||
|
||||
class ApiError(val tag: String, val errorCode: Int) {
|
||||
val id = System.currentTimeMillis()
|
||||
var profileId: Int? = null
|
||||
var throwable: Throwable? = null
|
||||
var apiResponse: String? = null
|
||||
@ -46,14 +47,6 @@ class ApiError(val tag: String, val errorCode: Int) {
|
||||
return this
|
||||
}
|
||||
|
||||
fun toAppError(): AppError {
|
||||
return AppError(
|
||||
tag,
|
||||
-1,
|
||||
errorCode, response, throwable, apiResponse
|
||||
)
|
||||
}
|
||||
|
||||
fun getStringText(context: Context): String {
|
||||
return context.resources.getIdentifier("error_${errorCode}", "string", context.packageName).let {
|
||||
if (it != 0)
|
||||
@ -91,6 +84,7 @@ class ApiError(val tag: String, val errorCode: Int) {
|
||||
"HTTP "+it.code()+" "+it.message()+"\n" + it.headers() + "\n\n" + it.parserErrorBody
|
||||
}
|
||||
return ErrorReportRequest.Error(
|
||||
id = id,
|
||||
tag = tag,
|
||||
errorCode = errorCode,
|
||||
errorText = getStringText(context),
|
||||
|
@ -9,6 +9,7 @@ data class ErrorReportRequest(
|
||||
val errors: List<Error>
|
||||
) {
|
||||
data class Error(
|
||||
val id: Long,
|
||||
val tag: String,
|
||||
val errorCode: Int,
|
||||
val errorText: String?,
|
||||
|
Loading…
x
Reference in New Issue
Block a user