Tidy up modal error
It now works if it's passed a string, as well as an Error.
This commit is contained in:
parent
7dd4c1f4c6
commit
7d497fcf73
1 changed files with 7 additions and 14 deletions
|
|
@ -138,26 +138,19 @@ Vue.mixin({
|
||||||
},
|
},
|
||||||
|
|
||||||
getErrorMessage: function(error) {
|
getErrorMessage: function(error) {
|
||||||
var errormsg = "";
|
// If a response was obtained, format it nicely and return it
|
||||||
|
|
||||||
// If a response was obtained
|
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
// If the response is a nicely formatted JSON response from the server
|
// If the response is a nicely formatted JSON response from the server
|
||||||
if (error.response.data.message) {
|
if (error.response.data.message) {
|
||||||
errormsg = `${error.response.status}: ${error.response.data.message}`;
|
return `${error.response.status}: ${error.response.data.message}`;
|
||||||
}
|
}
|
||||||
// If the response is just some generic error response
|
// If the response is just some generic error response
|
||||||
else {
|
return `${error.response.status}: ${error.response.data}`;
|
||||||
errormsg = `${error.response.status}: ${error.response.data}`;
|
|
||||||
}
|
|
||||||
// If the error occured during the request
|
|
||||||
} else if (error.request) {
|
|
||||||
errormsg = `${error.message}`;
|
|
||||||
// Everything else
|
|
||||||
} else {
|
|
||||||
errormsg = `${error.message}`;
|
|
||||||
}
|
}
|
||||||
return errormsg;
|
// If we have an error object with a message, use that
|
||||||
|
if (error.message) return `${error.message}`;
|
||||||
|
// Otherwise attempt to cast it to a string.
|
||||||
|
return `${error}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
showModalElement: function(element) {
|
showModalElement: function(element) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue