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:
@@ -211,7 +211,7 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
|
|||||||
});
|
});
|
||||||
return this.allCase;
|
return this.allCase;
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
if(error.response.status === 404) {
|
if(error.response?.status === 404) {
|
||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
|
|||||||
});
|
});
|
||||||
return this.allBaseCase;
|
return this.allBaseCase;
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
if(error.response.status === 404) {
|
if(error.response?.status === 404) {
|
||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ export const useConformanceStore = defineStore('conformanceStore', {
|
|||||||
this.allCases = response.data.cases;
|
this.allCases = response.data.cases;
|
||||||
return response.data.cases;
|
return response.data.cases;
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
if(error.response.status === 404) {
|
if(error.response?.status === 404) {
|
||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -350,7 +350,7 @@ export const useConformanceStore = defineStore('conformanceStore', {
|
|||||||
this.allLoopCases = response.data.cases;
|
this.allLoopCases = response.data.cases;
|
||||||
return response.data.cases;
|
return response.data.cases;
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
if(error.response.status === 404) {
|
if(error.response?.status === 404) {
|
||||||
this.infinite404 = 404;
|
this.infinite404 = 404;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export const useFilesStore = defineStore('filesStore', {
|
|||||||
this.$router.push({name: 'Upload'});
|
this.$router.push({name: 'Upload'});
|
||||||
Swal.close(); // 關閉進度條
|
Swal.close(); // 關閉進度條
|
||||||
} catch(error) {
|
} 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'
|
// 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'
|
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
|
||||||
const detail = error.response.data.detail;
|
const detail = error.response.data.detail;
|
||||||
@@ -199,7 +199,7 @@ export const useFilesStore = defineStore('filesStore', {
|
|||||||
await uploadSuccess();
|
await uploadSuccess();
|
||||||
this.$router.push({name: 'Files'});
|
this.$router.push({name: 'Files'});
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
if(error.response.status === 422) {
|
if(error.response?.status === 422) {
|
||||||
const detail = [...error.response.data.detail];
|
const detail = [...error.response.data.detail];
|
||||||
|
|
||||||
uploadFailedSecond(detail);
|
uploadFailedSecond(detail);
|
||||||
|
|||||||
Reference in New Issue
Block a user