Feat badnetwork exeptions (#122)

* feat: [BADNETWORK] exceptions

* added errors on okhttp

* added errors on okhttp

* feat: [BADNETWORK] exceptions

* feat: [BADNETWORK] exceptions

---------

Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
Florent CHAMPIGNY 2025-08-20 16:45:53 +02:00 committed by GitHub
parent cae29db95c
commit db3c8a118c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 491 additions and 191 deletions

View file

@ -134,11 +134,21 @@ fun toRemote(domain: BadQualityConfigDomainModel): BadQualityConfigDataModel = B
},
errorProbability = domain.errorProbability,
errors = domain.errors.map {
BadQualityConfigDataModel.Error(
weight = it.weight,
errorCode = it.httpCode,
errorBody = it.body,
errorContentType = it.contentType,
)
when(val t = it.type) {
is BadQualityConfigDomainModel.Error.Type.Body -> BadQualityConfigDataModel.Error(
weight = it.weight,
errorCode = t.httpCode,
errorBody = t.body,
errorContentType = t.contentType,
errorException = null,
)
is BadQualityConfigDomainModel.Error.Type.Exception -> BadQualityConfigDataModel.Error(
weight = it.weight,
errorException = t.classPath,
errorCode = null,
errorBody = null,
errorContentType = null,
)
}
},
)

View file

@ -18,8 +18,9 @@ data class BadQualityConfigDataModel(
@Serializable
data class Error(
val weight: Float, // increase the probability of being triggered vs all others errors
val errorCode: Int,
val errorBody: String,
val errorContentType: String, // "application/json"
val errorException: String?,
val errorCode: Int?,
val errorBody: String?,
val errorContentType: String?, // "application/json"
)
}