Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle BOM validation errors #762

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ')',
Expand Down
13 changes: 4 additions & 9 deletions src/views/portfolio/projects/ProjectUploadBomModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
},
},
};
Expand Down
13 changes: 4 additions & 9 deletions src/views/portfolio/projects/ProjectUploadVexModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
},
},
};
Expand Down
Loading