This commit is contained in:
2020-12-08 19:02:53 +00:00
parent e792050a0c
commit 4dd7adc1fd
4 changed files with 30 additions and 11 deletions

View File

@@ -28,6 +28,10 @@ ACTIONS:
Remove the routes that were being used for inside and outside user lists as they are no longer reqd. Remove the routes that were being used for inside and outside user lists as they are no longer reqd.
$profit $profit
todo: throw new Error() code *MUST* put only a string into the constructor of error. Putting a object is wrong and will result in errors that say "Error: [object Object]"
Search for all instances of throw new Error and ensure it's a string not an object, use stringify if necessary when all else fails
or a central function that turns any error object into a human readable message and inserts that into the error text
See extension-export-control.vue line 45 for example
todo: seeder subcontractor user no vendor attached? todo: seeder subcontractor user no vendor attached?

View File

@@ -68,18 +68,23 @@ function dealWithError(msg, vm) {
// and return human readable text // and return human readable text
// //
function decodeError(e, vm) { function decodeError(e, vm) {
// console.log("decodeError The e object is an object:"); // console.log("decodeError full e object as is: ");
// //console.log(JSON.stringify(e));
// console.log(typeof e === "object");
//empty?
// console.log("e instanceof Error ", e instanceof Error);
// console.log(e); // console.log(e);
// console.log("decodeError full e object stringified: ", JSON.stringify(e));
// console.log("decodeError is typeof:", typeof e);
// console.log("decodeError e is instanceof Error ", e instanceof Error);
// console.log(
// "decodeError e is a string already: ",
// window.$gz.util.isString(e)
// );
//console.log("Object.keys(e)", Object.keys(e)); //already a string?
if (window.$gz.util.isString(e)) {
return e; //nothing to do here, already a string
}
//an Error object?
if (e instanceof Error) { if (e instanceof Error) {
//an Error object?
return `Error - Name:${e.name}, Message:${e.message}`; return `Error - Name:${e.name}, Message:${e.message}`;
} }
@@ -177,6 +182,13 @@ export default {
handleFormError(err, vm) { handleFormError(err, vm) {
//called inside forms when things go unexpectedly wrong //called inside forms when things go unexpectedly wrong
dealWithError(decodeError(err, vm), vm); dealWithError(decodeError(err, vm), vm);
},
/////////////////////////////////////////////////
// decode error into string suitable to display
//
errorToString(err, vm) {
//called inside forms when things go unexpectedly wrong
return decodeError(err, vm);
} }
}; };
/* /*

View File

@@ -42,7 +42,8 @@ export default {
//call api route //call api route
let res = await window.$gz.api.upsert(url, body); let res = await window.$gz.api.upsert(url, body);
if (res.error) { if (res.error) {
throw new Error(res.error); //Error object constructor must be a string
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} }
let href = window.$gz.api.genericDownloadUrl( let href = window.$gz.api.genericDownloadUrl(
@@ -55,6 +56,7 @@ export default {
} }
} catch (error) { } catch (error) {
window.$gz.errorHandler.handleFormError(error, vm); window.$gz.errorHandler.handleFormError(error, vm);
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("JobFailed"));
} }
} }
}, },

View File

@@ -237,7 +237,8 @@ Vue.prototype.$ay = {
return locale.currencyLocalized(value); return locale.currencyLocalized(value);
} }
}; };
//disable the devtools nag
Vue.config.devtools = false;
new Vue({ new Vue({
vuetify: Vuetify, vuetify: Vuetify,
router, router,