throw "string" -> throw new Error("string"

This commit is contained in:
2020-09-16 17:37:22 +00:00
parent 3dc5f8134c
commit f67379f83f
31 changed files with 195 additions and 151 deletions

View File

@@ -139,11 +139,6 @@ export default {
vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
//route params MUST have source data
// if (!vm.$route.params.reportDataOptions) {
// throw "ay-report-edit::created - missing reportDataOptions route parameter";
// }
//id 0 means create a new record don't load one
if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation?
@@ -504,7 +499,7 @@ Handlebars.registerHelper('loud', function (aString) {
loading: true
});
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = "report/" + recordId;
try {
@@ -702,7 +697,9 @@ Handlebars.registerHelper('loud', function (aString) {
*/
let reportDataOptions = vm.$route.params.reportDataOptions;
if (!reportDataOptions) {
throw "Missing report data: to view report must come here from an object edit form or list so data can be provided for viewing the report";
throw new Error(
"Missing report data: to view report must come here from an object edit form or list so data can be provided for viewing the report"
);
}
reportDataOptions.ReportId = vm.obj.id;
@@ -936,17 +933,18 @@ async function fetchReportData(vm) {
if (!reportDataOptions) {
vm.reportData = null;
return;
// throw "ay-report-edit:fetchReportData - route parameter reportDataOptions is missing or empty, unable to init report designer";
}
if (reportDataOptions.ObjectType == null) {
throw "ay-report-edit:fetchReportData - route parameter ObjectType is missing or empty, unable to init report designer";
throw new Error(
"ay-report-edit:fetchReportData - route parameter ObjectType is missing or empty, unable to init report designer"
);
}
vm.obj.objectType = reportDataOptions.ObjectType;
let res = await window.$gz.api.upsert("report/data", reportDataOptions);
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw res;
throw new Error(res);
} else {
vm.reportData = res.data;
}