From 073c72fd635958ec8375c277b8a262ec3263b2f4 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:34:37 -0400 Subject: [PATCH] [F] Fix error response --- src/main/java/icu/samnyan/aqua/net/SettingsApi.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/icu/samnyan/aqua/net/SettingsApi.kt b/src/main/java/icu/samnyan/aqua/net/SettingsApi.kt index f91d3116..85d3caea 100644 --- a/src/main/java/icu/samnyan/aqua/net/SettingsApi.kt +++ b/src/main/java/icu/samnyan/aqua/net/SettingsApi.kt @@ -36,7 +36,7 @@ class SettingsApi( @API("set") @Doc("Set a field in the game options") 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 { userRepo.save(u.apply { gameOptions = it }) } @@ -46,7 +46,7 @@ class SettingsApi( type == String::class -> value type == Int::class -> value.toInt() type == Boolean::class -> value.toBoolean() - else -> error("Unsupported type") + else -> (400 - "Invalid field type $type") } field.set(options, newValue) }