Mercurial > gemma
changeset 413:a9440a4826aa
refactor: display errormessages refactored to own lib
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 15 Aug 2018 17:13:28 +0200 |
parents | 21fb992b1f5a |
children | c1047fd04a3a |
files | client/src/components/Userdetail.vue client/src/lib/errors.js client/src/views/Users.vue |
diffstat | 3 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Userdetail.vue Wed Aug 15 16:54:49 2018 +0200 +++ b/client/src/components/Userdetail.vue Wed Aug 15 17:13:28 2018 +0200 @@ -82,7 +82,7 @@ } </style> <script> -import app from "../main"; +import { displayError } from "../lib/errors.js"; const emptyErrormessages = () => { return { @@ -207,7 +207,7 @@ this.submitted = false; this.$store.dispatch("usermanagement/loadUsers").catch(error => { const { status, data } = error.response; - app.$toast.error({ + displayError({ title: "Backend Error", message: `${status}: ${data.message}` }); @@ -216,7 +216,7 @@ .catch(error => { this.submitted = false; const { status, data } = error.response; - app.$toast.error({ + displayError({ title: "Error while saving user", message: `${status}: ${data.message}` });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/lib/errors.js Wed Aug 15 17:13:28 2018 +0200 @@ -0,0 +1,11 @@ +import app from "../main"; + +const displayError = ({ title, message }) => { + console.log(message); + app.$toast.error({ + title: title, + message: message + }); +}; + +export { displayError };
--- a/client/src/views/Users.vue Wed Aug 15 16:54:49 2018 +0200 +++ b/client/src/views/Users.vue Wed Aug 15 17:13:28 2018 +0200 @@ -96,7 +96,7 @@ import Userdetail from "../components/Userdetail"; import store from "../store"; import { mapGetters } from "vuex"; -import app from "../main"; +import { displayError } from "../lib/errors.js"; export default { name: "userview", @@ -126,7 +126,7 @@ this.submitted = false; this.$store.dispatch("usermanagement/loadUsers").catch(error => { const { status, data } = error.response; - app.$toast.error({ + displayError({ title: "Backend Error", message: `${status}: ${data.message}` }); @@ -134,7 +134,7 @@ }) .catch(error => { const { status, data } = error.response; - app.$toast.error({ + displayError({ title: "Backend Error", message: `${status}: ${data.message}` }); @@ -155,9 +155,9 @@ .then(next) .catch(error => { const { status, data } = error.response; - app.$toast.error({ + displayError({ title: "Backend Error", - message: `${status}: ${data.message}` + message: `${status}: ${data}` }); }); },