modify error message

This commit is contained in:
MaysWind
2025-03-30 00:38:33 +08:00
parent 6dfff84ab7
commit 433a225b9d
3 changed files with 34 additions and 2 deletions
+32
View File
@@ -331,6 +331,37 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
}
function addCategories(req: TransactionCategoryCreateBatchRequest): Promise<Record<number, TransactionCategory[]>> {
return new Promise((resolve, reject) => {
services.addTransactionCategoryBatch(req).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to add category' });
return;
}
if (!transactionCategoryListStateInvalid.value) {
updateTransactionCategoryListInvalidState(true);
}
const transactionCategories = TransactionCategory.ofMap(data.result);
resolve(transactionCategories);
}).catch(error => {
logger.error('failed to add categories', error);
if (error.response && error.response.data && error.response.data.errorMessage) {
reject({ error: error.response.data });
} else if (!error.processed) {
reject({ message: 'Unable to add category' });
} else {
reject(error);
}
});
});
}
function addPresetCategories(req: TransactionCategoryCreateBatchRequest): Promise<Record<number, TransactionCategory[]>> {
return new Promise((resolve, reject) => {
services.addTransactionCategoryBatch(req).then(response => {
const data = response.data;
@@ -535,6 +566,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
getCategory,
saveCategory,
addCategories,
addPresetCategories,
changeCategoryDisplayOrder,
updateCategoryDisplayOrders,
hideCategory,
@@ -117,7 +117,7 @@ function save(): void {
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
transactionCategoriesStore.addCategories({
transactionCategoriesStore.addPresetCategories({
categories: submitCategories
}).then(() => {
submitting.value = false;
+1 -1
View File
@@ -113,7 +113,7 @@ function save(): void {
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
transactionCategoriesStore.addCategories({
transactionCategoriesStore.addPresetCategories({
categories: submitCategories
}).then(() => {
submitting.value = false;