Drop unused error parameter from apiError
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RaRBJFZKSTA7naHGuQHfnQ
This commit is contained in:
@@ -14,10 +14,9 @@ import "vue-toast-notification/dist/theme-sugar.css";
|
|||||||
* 401 errors are handled by the axios response interceptor
|
* 401 errors are handled by the axios response interceptor
|
||||||
* in api/client.js.
|
* in api/client.js.
|
||||||
*
|
*
|
||||||
* @param {Object} error - The error object from the API call.
|
|
||||||
* @param {string} toastMessage - The message to display in the toast.
|
* @param {string} toastMessage - The message to display in the toast.
|
||||||
*/
|
*/
|
||||||
export default function apiError(error, toastMessage) {
|
export default function apiError(toastMessage) {
|
||||||
const $toast = useToast();
|
const $toast = useToast();
|
||||||
$toast.default(toastMessage, { position: "bottom" });
|
$toast.default(toastMessage, { position: "bottom" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
const customizedResponseData = await this.customizeAllUserList(response.data);
|
const customizedResponseData = await this.customizeAllUserList(response.data);
|
||||||
this.allUserAccountList = await this.moveCurrentLoginUserToFirstRow(customizedResponseData);
|
this.allUserAccountList = await this.moveCurrentLoginUserToFirstRow(customizedResponseData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to get all users.');
|
apiError('Failed to get all users.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +155,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
setTimeout(() => this.resetJustCreateFlag(), JUST_CREATE_ACCOUNT_HOT_DURATION_MINS * 1000 * 60);
|
setTimeout(() => this.resetJustCreateFlag(), JUST_CREATE_ACCOUNT_HOT_DURATION_MINS * 1000 * 60);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to add a new account.');
|
apiError('Failed to add a new account.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +170,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
const response = await apiClient.delete(apiDelete);
|
const response = await apiClient.delete(apiDelete);
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to delete the account.');
|
apiError('Failed to delete the account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -191,7 +191,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
});
|
});
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to edit the account.');
|
apiError('Failed to edit the account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -207,7 +207,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
});
|
});
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to edit name of account.');
|
apiError('Failed to edit name of account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -224,7 +224,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
});
|
});
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to edit password of account.');
|
apiError('Failed to edit password of account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -239,7 +239,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
const response = await apiClient.put(apiAddRole);
|
const response = await apiClient.put(apiAddRole);
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to add role to the account.');
|
apiError('Failed to add role to the account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -254,7 +254,7 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
|||||||
const response = await apiClient.delete(apiDeleteRole);
|
const response = await apiClient.delete(apiDeleteRole);
|
||||||
return response.status === 200;
|
return response.status === 200;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, 'Failed to delete a role from the account.');
|
apiError('Failed to delete a role from the account.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-10
@@ -172,7 +172,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.allStats = response.data.stats;
|
this.allStats = response.data.stats;
|
||||||
this.allInsights = response.data.insights;
|
this.allInsights = response.data.insights;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Map.");
|
apiError("Failed to load the Map.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +191,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.allBaseTrace = baseResponse.data;
|
this.allBaseTrace = baseResponse.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Trace.");
|
apiError("Failed to load the Trace.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -233,7 +233,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apiError(error, "Failed to load the Trace Detail.");
|
apiError("Failed to load the Trace Detail.");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -278,7 +278,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apiError(error, "Failed to load the Base Trace Detail.");
|
apiError("Failed to load the Base Trace Detail.");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -309,7 +309,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.allFilterTimeframe.x_axis.max =
|
this.allFilterTimeframe.x_axis.max =
|
||||||
max === null ? null : moment(max).format("YYYY/MM/DD HH:mm");
|
max === null ? null : moment(max).format("YYYY/MM/DD HH:mm");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Filter Parameters.");
|
apiError("Failed to load the Filter Parameters.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -323,7 +323,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
const response = await apiClient.post(api, this.postRuleData);
|
const response = await apiClient.post(api, this.postRuleData);
|
||||||
this.hasResultRule = response.data.result;
|
this.hasResultRule = response.data.result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Has Result.");
|
apiError("Failed to load the Has Result.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -337,7 +337,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
const response = await apiClient.post(api, this.postRuleData);
|
const response = await apiClient.post(api, this.postRuleData);
|
||||||
this.tempFilterId = response.data.id;
|
this.tempFilterId = response.data.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to add the Temporary Filters.");
|
apiError("Failed to add the Temporary Filters.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -357,7 +357,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.createFilterId = response.data.id;
|
this.createFilterId = response.data.id;
|
||||||
this.tempFilterId = null;
|
this.tempFilterId = null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Filters.");
|
apiError("Failed to load the Filters.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -375,7 +375,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.filterName = response.data.name;
|
this.filterName = response.data.name;
|
||||||
this.baseLogId = response.data.log?.id;
|
this.baseLogId = response.data.log?.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to get Filter Detail.");
|
apiError("Failed to get Filter Detail.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -392,7 +392,7 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
|
|||||||
this.isUpdateFilter = response.status === 200;
|
this.isUpdateFilter = response.status === 200;
|
||||||
this.tempFilterId = null;
|
this.tempFilterId = null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to update an Existing Filter.");
|
apiError("Failed to update an Existing Filter.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const useCompareStore = defineStore("compareStore", {
|
|||||||
const response = await apiClient.get(api);
|
const response = await apiClient.get(api);
|
||||||
this.allCompareDashboardData = response.data;
|
this.allCompareDashboardData = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Compare.");
|
apiError("Failed to load the Compare.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ export const useCompareStore = defineStore("compareStore", {
|
|||||||
|
|
||||||
return response.data.stats;
|
return response.data.stats;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Compare's States.");
|
apiError("Failed to load the Compare's States.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -79,7 +79,7 @@ export const useCompareStore = defineStore("compareStore", {
|
|||||||
|
|
||||||
if (file) return file.name;
|
if (file) return file.name;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Compare's file name.");
|
apiError("Failed to load the Compare's file name.");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.allWaitingTime = response.data.waiting_time;
|
this.allWaitingTime = response.data.waiting_time;
|
||||||
this.allCycleTime = response.data.cycle_time;
|
this.allCycleTime = response.data.cycle_time;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Conformance Parameters.");
|
apiError("Failed to load the Conformance Parameters.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -295,7 +295,7 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.conformanceLogTempCheckId = response.data.id;
|
this.conformanceLogTempCheckId = response.data.id;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to add the Temporary Check for a file.");
|
apiError("Failed to add the Temporary Check for a file.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -312,7 +312,7 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.allConformanceTempReportData = response.data;
|
this.allConformanceTempReportData = response.data;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to Get the Temporary Log Conformance Report.");
|
apiError("Failed to Get the Temporary Log Conformance Report.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -326,7 +326,6 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.allIssueTraces = response.data.traces;
|
this.allIssueTraces = response.data.traces;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(
|
apiError(
|
||||||
error,
|
|
||||||
"Failed to Get the detail of a temporary log conformance issue.",
|
"Failed to Get the detail of a temporary log conformance issue.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -350,7 +349,6 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
apiError(
|
apiError(
|
||||||
error,
|
|
||||||
"Failed to Get the detail of a temporary log conformance issue.",
|
"Failed to Get the detail of a temporary log conformance issue.",
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
@@ -367,7 +365,6 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.allLoopTraces = response.data.traces;
|
this.allLoopTraces = response.data.traces;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(
|
apiError(
|
||||||
error,
|
|
||||||
"Failed to Get the detail of a temporary log conformance loop.",
|
"Failed to Get the detail of a temporary log conformance loop.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -391,7 +388,6 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
apiError(
|
apiError(
|
||||||
error,
|
|
||||||
"Failed to Get the detail of a temporary log conformance loop.",
|
"Failed to Get the detail of a temporary log conformance loop.",
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
@@ -419,7 +415,7 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.conformanceLogTempCheckId = null;
|
this.conformanceLogTempCheckId = null;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to add the Conformance Check for a file.");
|
apiError("Failed to add the Conformance Check for a file.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -435,7 +431,7 @@ export const useConformanceStore = defineStore("conformanceStore", {
|
|||||||
this.conformanceLogTempCheckId = null;
|
this.conformanceLogTempCheckId = null;
|
||||||
this.conformanceFilterTempCheckId = null;
|
this.conformanceFilterTempCheckId = null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to update an Existing Conformance.");
|
apiError("Failed to update an Existing Conformance.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
+9
-9
@@ -146,7 +146,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
: null;
|
: null;
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the files.");
|
apiError("Failed to load the files.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -180,7 +180,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Swal.close(); // Close the loading progress bar
|
Swal.close(); // Close the loading progress bar
|
||||||
apiError(error, "Failed to upload the files.");
|
apiError("Failed to upload the files.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -195,7 +195,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
const response = await apiClient.get(api);
|
const response = await apiClient.get(api);
|
||||||
this.allUploadDetail = response.data.preview;
|
this.allUploadDetail = response.data.preview;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to get upload detail.");
|
apiError("Failed to get upload detail.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +223,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
uploadFailedSecond(detail);
|
uploadFailedSecond(detail);
|
||||||
} else {
|
} else {
|
||||||
Swal.close(); // Close the loading progress bar
|
Swal.close(); // Close the loading progress bar
|
||||||
apiError(error, "Failed to upload the log files.");
|
apiError("Failed to upload the log files.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -247,7 +247,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
this.uploadFileName = null;
|
this.uploadFileName = null;
|
||||||
await this.fetchAllFiles();
|
await this.fetchAllFiles();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to rename.");
|
apiError("Failed to rename.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -262,7 +262,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
);
|
);
|
||||||
this.allDependentsData = response.data;
|
this.allDependentsData = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to get Dependents of the files.");
|
apiError("Failed to get Dependents of the files.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -282,7 +282,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
await this.fetchAllFiles();
|
await this.fetchAllFiles();
|
||||||
await deleteSuccess();
|
await deleteSuccess();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to delete.");
|
apiError("Failed to delete.");
|
||||||
} finally {
|
} finally {
|
||||||
loading.isLoading = false;
|
loading.isLoading = false;
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
try {
|
try {
|
||||||
await apiClient.delete(api);
|
await apiClient.delete(api);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to Remove a Deletion Record.");
|
apiError("Failed to Remove a Deletion Record.");
|
||||||
} finally {
|
} finally {
|
||||||
loading.isLoading = false;
|
loading.isLoading = false;
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
link.click();
|
link.click();
|
||||||
globalThis.URL.revokeObjectURL(url);
|
globalThis.URL.revokeObjectURL(url);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to download.");
|
apiError("Failed to download.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ export const useLoginStore = defineStore("loginStore", {
|
|||||||
|
|
||||||
this.userData = response.data;
|
this.userData = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load user data.");
|
apiError("Failed to load user data.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const usePerformanceStore = defineStore("performanceStore", {
|
|||||||
const response = await apiClient.get(api);
|
const response = await apiClient.get(api);
|
||||||
this.allPerformanceData = response.data;
|
this.allPerformanceData = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
apiError(error, "Failed to load the Performance.");
|
apiError("Failed to load the Performance.");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// The Lucia project.
|
||||||
|
// Copyright 2026-2026 DSP, inc. All rights reserved.
|
||||||
|
// Authors:
|
||||||
|
// imacat.yang@dsp.im (imacat), 2026/07/04
|
||||||
|
// AI assistance: Claude Code (Anthropic)
|
||||||
|
|
||||||
|
import { describe, it, expect, vi } from "vitest";
|
||||||
|
import apiError from "@/module/apiError.js";
|
||||||
|
|
||||||
|
const toastDefault = vi.fn();
|
||||||
|
|
||||||
|
vi.mock("vue-toast-notification", () => ({
|
||||||
|
useToast: () => ({ default: toastDefault }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("apiError", () => {
|
||||||
|
it("shows the message as a toast at the bottom", () => {
|
||||||
|
apiError("some message");
|
||||||
|
expect(toastDefault).toHaveBeenCalledWith("some message", {
|
||||||
|
position: "bottom",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user