Harmonize JSON API error messages

This commit is contained in:
2026-08-25 23:44:26 +02:00
parent 0d4b159ab3
commit f1b90a4d83
18 changed files with 254 additions and 175 deletions
+9 -8
View File
@@ -10,8 +10,8 @@ export default class Api {
}
async get(sAction, asParams = {}) {
const response = await this.request(sAction, asParams, 'GET');
return response.data;
const oResponse = await this.request(sAction, asParams, 'GET');
return oResponse.data;
}
async getAsset(sAssetPath) {
@@ -25,8 +25,8 @@ export default class Api {
}
async post(sAction, asParams = {}) {
const response = await this.request(sAction, asParams, 'POST');
return response.data;
const oResponse = await this.request(sAction, asParams, 'POST');
return oResponse.data;
}
async request(sAction, asParams = {}, method = 'GET') {
@@ -59,12 +59,13 @@ export default class Api {
}
const oResponse = await oRequest.json();
oResponse.descKey = this.lang.getLangKey(oResponse.desc);
oResponse.desc = this.lang.parse(oResponse.desc);
oResponse.desc_lang_text = this.lang.get(oResponse.desc_lang_id, oResponse.desc_lang_params);
if(oResponse.result == this.errorCode) {
const oError = new Error(oResponse.desc);
oError.descKey = oResponse.descKey;
const oError = new Error(oResponse.desc_lang_text);
oError.desc_lang_id = oResponse.desc_lang_id;
oError.desc_lang_params = oResponse.desc_lang_params;
oError.desc_lang_text = oResponse.desc_lang_text;
throw oError;
}