Add optional chaining to error.response.status in catch blocks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 07:55:49 +08:00
parent eeea16be38
commit 2a4aa9db00
3 changed files with 6 additions and 6 deletions

View File

@@ -155,7 +155,7 @@ export const useFilesStore = defineStore('filesStore', {
this.$router.push({name: 'Upload'});
Swal.close(); // 關閉進度條
} catch(error) {
if(error.response.status === 422) {
if(error.response?.status === 422) {
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
const detail = error.response.data.detail;
@@ -199,7 +199,7 @@ export const useFilesStore = defineStore('filesStore', {
await uploadSuccess();
this.$router.push({name: 'Files'});
} catch(error) {
if(error.response.status === 422) {
if(error.response?.status === 422) {
const detail = [...error.response.data.detail];
uploadFailedSecond(detail);