mirror of
https://github.com/openflocon/Flocon.git
synced 2026-05-10 03:29:17 +00:00
Fix badcondition mapping (#361)
Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
parent
26daf23c6d
commit
3380d2f477
2 changed files with 9 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package io.github.openflocon.flocon.plugins.network.model
|
||||
|
||||
import io.github.openflocon.flocon.FloconLogger
|
||||
import kotlin.random.Random
|
||||
|
||||
data class BadQualityConfig(
|
||||
|
|
@ -36,8 +37,13 @@ data class BadQualityConfig(
|
|||
val classPath: String,
|
||||
) : Type {
|
||||
fun generate() : Throwable? {
|
||||
val errorClass = Class.forName(classPath)
|
||||
return errorClass.newInstance() as? Throwable
|
||||
return try {
|
||||
val errorClass = Class.forName(classPath)
|
||||
errorClass.newInstance() as? Throwable
|
||||
} catch (t: Throwable) {
|
||||
FloconLogger.logError("BadQualityConfig error, className not found", t)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ fun parseBadQualityConfig(jsonString: String): BadQualityConfig? {
|
|||
val errorContentType = errorObject.optString("errorContentType")
|
||||
val error = BadQualityConfig.Error(
|
||||
weight = errorObject.getDouble("weight").toFloat(),
|
||||
type = if (errorException.isNotEmpty()) {
|
||||
type = if (errorException.isNotEmpty() && errorException != "null") {
|
||||
BadQualityConfig.Error.Type.ErrorThrow(errorException)
|
||||
} else {
|
||||
BadQualityConfig.Error.Type.Body(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue