diff --git a/src/App.vue b/src/App.vue index 380c56467..02ce9bec0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -71,12 +71,20 @@ export default { } this.axios.interceptors.response.use(null, (error) => { - // On error status codes (4xx - 5xx), display a toast with the HTTP status code and text. + // On error status codes (4xx - 5xx), display a toast with either: + // * The problem title and detail in case of an RFC 9457 response + // * the HTTP status code and text if (error.response.status >= 400 && error.response.status < 500) { - this.$toastr.e( - error.response.statusText + ' (' + error.response.status + ')', - this.$t('condition.http_request_error'), - ); + if ( + error.response.headers['content-type'] === 'application/problem+json' + ) { + this.$toastr.w(error.response.data.detail, error.response.data.title); + } else { + this.$toastr.e( + error.response.statusText + ' (' + error.response.status + ')', + this.$t('condition.http_request_error'), + ); + } } else { this.$toastr.e( error.response.statusText + ' (' + error.response.status + ')', diff --git a/src/views/portfolio/projects/ProjectUploadBomModal.vue b/src/views/portfolio/projects/ProjectUploadBomModal.vue index abdb1675c..c22177f1b 100644 --- a/src/views/portfolio/projects/ProjectUploadBomModal.vue +++ b/src/views/portfolio/projects/ProjectUploadBomModal.vue @@ -57,15 +57,10 @@ export default { }, }; let url = `${this.$api.BASE_URL}/${this.$api.URL_BOM}`; - this.axios - .post(url, data, config) - .then((response) => { - this.$root.$emit('bv::hide::modal', 'projectUploadBomModal'); - this.$toastr.s(this.$t('message.bom_uploaded')); - }) - .catch((error) => { - this.$toastr.w(this.$t('condition.unsuccessful_action')); - }); + this.axios.post(url, data, config).then(() => { + this.$root.$emit('bv::hide::modal', 'projectUploadBomModal'); + this.$toastr.s(this.$t('message.bom_uploaded')); + }); }, }, }; diff --git a/src/views/portfolio/projects/ProjectUploadVexModal.vue b/src/views/portfolio/projects/ProjectUploadVexModal.vue index 8066d9e26..189888e0f 100644 --- a/src/views/portfolio/projects/ProjectUploadVexModal.vue +++ b/src/views/portfolio/projects/ProjectUploadVexModal.vue @@ -57,15 +57,10 @@ export default { }, }; let url = `${this.$api.BASE_URL}/${this.$api.URL_VEX}`; - this.axios - .post(url, data, config) - .then((response) => { - this.$root.$emit('bv::hide::modal', 'projectUploadVexModal'); - this.$toastr.s(this.$t('message.vex_uploaded')); - }) - .catch((error) => { - this.$toastr.w(this.$t('condition.unsuccessful_action')); - }); + this.axios.post(url, data, config).then(() => { + this.$root.$emit('bv::hide::modal', 'projectUploadVexModal'); + this.$toastr.s(this.$t('message.vex_uploaded')); + }); }, }, };