From 6a5261b5f662c1195b8c4d7ea1f5058b607b5f0a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 17 Mar 2024 16:30:18 +0100 Subject: [PATCH] Rebuild JS artifacts --- .../files/js/WoltLabSuite/Core/Api/Error.js | 20 ++++++++++++++++++- .../files/js/WoltLabSuite/Core/Api/Result.js | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Error.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Error.js index cb571bbf8a..3360323316 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Error.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Error.js @@ -7,12 +7,30 @@ define(["require", "exports"], function (require, exports) { code; message; param; - constructor(type, code, message, param) { + statusCode; + constructor(type, code, message, param, statusCode) { this.type = type; this.code = code; this.message = message; this.param = param; + this.statusCode = statusCode; + } + getValidationError() { + if (this.type !== "invalid_request_error" || this.statusCode !== 400) { + return undefined; + } + return new ValidationError(this.code, this.message, this.param); } } exports.ApiError = ApiError; + class ValidationError { + code; + message; + param; + constructor(code, message, param) { + this.code = code; + this.message = message; + this.param = param; + } + } }); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Result.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Result.js index 76fa08ce86..2dce313e22 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Result.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Api/Result.js @@ -45,7 +45,7 @@ define(["require", "exports", "../Core", "./Error"], function (require, exports, typeof json.code === "string" && typeof json.message === "string" && typeof json.param === "string") { - return apiResultFromError(new Error_1.ApiError(json.type, json.code, json.message, json.param)); + return apiResultFromError(new Error_1.ApiError(json.type, json.code, json.message, json.param, response.status)); } throw e; } -- 2.20.1