Skip to content

Commit

Permalink
fix(#924): parse new error format in UI (#1082)
Browse files Browse the repository at this point in the history
(cherry picked from commit c9ac1ca)
  • Loading branch information
frascuchon committed Feb 2, 2022
1 parent 2ec0079 commit f26c79c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/plugins/vuex-orm-axios.js
Expand Up @@ -44,15 +44,22 @@ export default ({ $axios, app }) => {
app.$auth.logout();
}

const messageDetail = error.response.data.detail || {
code: undefined,
params: {},
};

switch (code) {
case 400:
Notification.dispatch("notify", {
message: "Error: " + error.response.data.detail,
message: Object.entries(messageDetail.params)
.map(([k, v]) => `Error ${k}: ${v}`)
.join("\n"),
type: "error",
});
break;
case 422:
(error.response.data.detail || [undefined]).forEach(({ msg }) => {
(messageDetail.params.errors || [undefined]).forEach(({ msg }) => {
Notification.dispatch("notify", {
message: "Error: " + (msg || "Unknown"),
type: "error",
Expand Down

0 comments on commit f26c79c

Please sign in to comment.