[Errors] Add reporting the error ID.

This commit is contained in:
Kuba Szczodrzyński 2019-12-31 14:28:37 +01:00
parent 62ae3c4c4b
commit 344da53888
2 changed files with 3 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import pl.szczodrzynski.edziennik.data.api.szkolny.request.ErrorReportRequest
import pl.szczodrzynski.edziennik.stackTraceString import pl.szczodrzynski.edziennik.stackTraceString
class ApiError(val tag: String, val errorCode: Int) { class ApiError(val tag: String, val errorCode: Int) {
val id = System.currentTimeMillis()
var profileId: Int? = null var profileId: Int? = null
var throwable: Throwable? = null var throwable: Throwable? = null
var apiResponse: String? = null var apiResponse: String? = null
@ -46,14 +47,6 @@ class ApiError(val tag: String, val errorCode: Int) {
return this return this
} }
fun toAppError(): AppError {
return AppError(
tag,
-1,
errorCode, response, throwable, apiResponse
)
}
fun getStringText(context: Context): String { fun getStringText(context: Context): String {
return context.resources.getIdentifier("error_${errorCode}", "string", context.packageName).let { return context.resources.getIdentifier("error_${errorCode}", "string", context.packageName).let {
if (it != 0) 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 "HTTP "+it.code()+" "+it.message()+"\n" + it.headers() + "\n\n" + it.parserErrorBody
} }
return ErrorReportRequest.Error( return ErrorReportRequest.Error(
id = id,
tag = tag, tag = tag,
errorCode = errorCode, errorCode = errorCode,
errorText = getStringText(context), errorText = getStringText(context),

View File

@ -9,6 +9,7 @@ data class ErrorReportRequest(
val errors: List<Error> val errors: List<Error>
) { ) {
data class Error( data class Error(
val id: Long,
val tag: String, val tag: String,
val errorCode: Int, val errorCode: Int,
val errorText: String?, val errorText: String?,