mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 13:47:26 +08:00
[F] Fix error response
This commit is contained in:
@@ -36,7 +36,7 @@ class SettingsApi(
|
|||||||
@API("set")
|
@API("set")
|
||||||
@Doc("Set a field in the game options")
|
@Doc("Set a field in the game options")
|
||||||
fun setField(@RP token: String, @RP key: String, @RP value: String) = us.jwt.auth(token) { u ->
|
fun setField(@RP token: String, @RP key: String, @RP value: String) = us.jwt.auth(token) { u ->
|
||||||
val field = fieldMap[key] ?: error("Field not found")
|
val field = fieldMap[key] ?: (400 - "Invalid field $key")
|
||||||
val options = u.gameOptions ?: AquaGameOptions().also {
|
val options = u.gameOptions ?: AquaGameOptions().also {
|
||||||
userRepo.save(u.apply { gameOptions = it })
|
userRepo.save(u.apply { gameOptions = it })
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ class SettingsApi(
|
|||||||
type == String::class -> value
|
type == String::class -> value
|
||||||
type == Int::class -> value.toInt()
|
type == Int::class -> value.toInt()
|
||||||
type == Boolean::class -> value.toBoolean()
|
type == Boolean::class -> value.toBoolean()
|
||||||
else -> error("Unsupported type")
|
else -> (400 - "Invalid field type $type")
|
||||||
}
|
}
|
||||||
field.set(options, newValue)
|
field.set(options, newValue)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user