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

@@ -203,7 +203,7 @@ export default {
//call seed route
let jobId = await window.$gz.api.upsert("attachment/maintenance");
if (jobId.error) {
throw jobId.error;
throw new Error(jobId.error);
}
jobId = jobId.jobId; //it's in a sub key
vm.jobActive = true;
@@ -229,11 +229,11 @@ export default {
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw jobStatus.error;
throw new Error(jobStatus.error);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {
throw "Seeding job failed";
throw new Error("Seeding job failed");
}
if (jobStatus == 3) {
vm.jobActive = false;

View File

@@ -388,11 +388,11 @@ export default {
//send request
r = await window.$gz.api.upsert("license/trialRequest", vm.request);
if (r.error) {
throw r;
throw new Error(r);
}
//a string is returned and will start with E1 if it's an error
if (r.startsWith("E1")) {
throw r;
throw new Error(r);
}
if (r == "ok") {
@@ -414,7 +414,7 @@ export default {
//It might have been just installed by the server on it's own so check if we are not working with the most current license
let currentServerLicenseInfo = await window.$gz.api.get("license");
if (currentServerLicenseInfo.error) {
throw currentServerLicenseInfo.error;
throw new Error(currentServerLicenseInfo.error);
}
currentServerLicenseInfo = currentServerLicenseInfo.data.license;
@@ -433,11 +433,11 @@ export default {
let r = await window.$gz.api.upsert("license");
//r should just be a string response unless there is an error in which case it's an object
if (r.error) {
throw r;
throw new Error(r);
}
if (r.startsWith("E1")) {
throw r;
throw new Error(r);
}
//If here, there is no technical error
//key might not exist or be not found but no error so r contains the deets
@@ -589,14 +589,14 @@ async function initForm(vm) {
let res = await window.$gz.api.get("license");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw res;
throw new Error(res);
}
vm.currentLicenseInfo = res.data.license;
res = await window.$gz.api.get("license/database-empty");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw res;
throw new Error(res);
}
vm.dbIsEmpty = res.data;
}

View File

@@ -344,7 +344,7 @@ export default {
vm.formState.loading = true;
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
try {

View File

@@ -411,7 +411,7 @@ export default {
vm.formState.loading = true;
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
try {

View File

@@ -299,7 +299,7 @@ async function getServerInfo(vm) {
let res = await window.$gz.api.get("server-info");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw res;
throw new Error(res);
} else {
vm.serverInfo = res.data;
}

View File

@@ -377,7 +377,7 @@ async function initDataObject(vm) {
let url = "form-field-definition/" + vm.$route.params.formCustomTemplateKey;
let res = await window.$gz.api.get(url);
if (res.error) {
throw res.error;
throw new Error(res.error);
}
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form
// - {key, ltdisplay, hideable, custom, required, hide, type}

View File

@@ -1191,7 +1191,7 @@ async function populateFieldDefinitions(vm) {
"data-list/listfields?DataListKey=" + vm.dataListKey
);
if (res.error) {
throw res.error;
throw new Error(res.error);
} else {
vm.fieldDefinitions = res.data;
}
@@ -1224,7 +1224,9 @@ async function setEffectiveListView(vm) {
*/
if (vm.listViewId == null) {
throw "ay-data-list::setEffectiveListView - listViewId is not set";
throw new Error(
"ay-data-list::setEffectiveListView - listViewId is not set"
);
}
let formSettings = window.$gz.form.getFormSettings(vm.formKey);
@@ -1245,7 +1247,7 @@ async function setEffectiveListView(vm) {
);
if (res.error) {
throw res.error;
throw new Error(res.error);
} else {
vm.effectiveListView = JSON.parse(res.data);
vm.obj.name = vm.$ay.t("FilterUnsaved");
@@ -1254,7 +1256,7 @@ async function setEffectiveListView(vm) {
//listview has an id value
let res = await window.$gz.api.get("data-list-view/" + vm.listViewId);
if (res.error) {
throw res.error;
throw new Error(res.error);
} else {
vm.effectiveListView = JSON.parse(res.data.listView);
vm.obj.public = res.data.public;
@@ -1269,10 +1271,14 @@ async function setEffectiveListView(vm) {
//
function initDataObject(vm) {
if (vm.effectiveListView == null) {
throw "ay-data-list::initDataObject - effectiveListView is not set";
throw new Error(
"ay-data-list::initDataObject - effectiveListView is not set"
);
}
if (vm.fieldDefinitions == null) {
throw "ay-data-list::initDataObject - fieldDefinitions are not set";
throw new Error(
"ay-data-list::initDataObject - fieldDefinitions are not set"
);
}
let ret = [];
@@ -1360,7 +1366,9 @@ function initDataObject(vm) {
if (window.$gz.dev) {
if (vm.obj.editView.length != vm.fieldDefinitions.length) {
throw "ay-data-list-view::initDataObject - working array length not equal to total field definition length";
throw new Error(
"ay-data-list-view::initDataObject - working array length not equal to total field definition length"
);
}
}
return Promise.resolve();
@@ -1438,7 +1446,9 @@ function getDisplayForFilter(
//Nothing more to do if there isn't both a value AND an operator at this point
if (filterOperator == null || filterValue == null) {
if (window.$gz.dev) {
throw "ay-data-list-view::getDisplayForFilter Value filter missing one ore more of Operator, Value";
throw new Error(
"ay-data-list-view::getDisplayForFilter Value filter missing one ore more of Operator, Value"
);
}
return "";
}

View File

@@ -205,7 +205,7 @@ export default {
let res = await window.$gz.api.get("license/database-empty");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw res;
throw new Error(res);
}
if (res.data != true) {
let dialogResult = await window.$gz.dialog.confirmGeneric(
@@ -235,7 +235,7 @@ export default {
`trial/seed/${vm.obj.seedLevel}/${vm.obj.timeZoneOffset}`
);
if (jobId.error) {
throw jobId.error;
throw new Error(jobId.error);
}
jobId = jobId.jobId; //it's in a sub key
//indicate loading by setting on button
@@ -262,11 +262,11 @@ export default {
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw jobStatus.error;
throw new Error(jobStatus.error);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {
throw "Seeding job failed";
throw new Error("Seeding job failed");
}
if (jobStatus == 3) {
vm.seedingJobActive = false;

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;
}

View File

@@ -415,7 +415,7 @@ export default {
vm.formState.loading = true;
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
try {

View File

@@ -212,7 +212,7 @@ export default {
//this is to ensure that when a user is viewing the latest notifications they don't see the NEW count still in the bell icon in menu since they are viewing them live
let status = await window.$gz.api.get("notify/new-count");
if (status.error) {
throw status.error;
throw new Error(status.error);
}
window.$gz.store.commit("setNewNotificationCount", status.data);
}

View File

@@ -403,7 +403,7 @@ export default {
vm.formState.loading = true;
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
try {

View File

@@ -310,7 +310,7 @@ export default {
if (res.error) {
//don't expect this to ever get called but just in case
throw res.error;
throw new Error(res.error);
}
await processLogin(res.data, loggedInWithKnownPassword);

View File

@@ -423,7 +423,7 @@ export default {
loading: true
});
if (!recordId) {
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
try {
@@ -611,61 +611,64 @@ async function clickHandler(menuItem) {
return;
}
let m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "save":
m.vm.submit();
break;
case "delete":
m.vm.remove();
break;
case "new":
m.vm.$router.push({
name: "widget-edit",
params: { recordid: 0, new: true }
});
break;
case "duplicate":
m.vm.duplicate();
break;
case "report":
// throw "blah blah blah";
// throw Error("test exception");
if (m.id != null) {
//last report selected is in m.id
try {
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "save":
m.vm.submit();
break;
case "delete":
m.vm.remove();
break;
case "new":
m.vm.$router.push({
name: "ay-report",
params: { recordid: m.id, ayatype: window.$gz.type.Widget }
name: "widget-edit",
params: { recordid: 0, new: true }
});
} else {
//general report selector chosen
break;
case "duplicate":
m.vm.duplicate();
break;
case "report":
if (m.id != null) {
//last report selected is in m.id
m.vm.$router.push({
name: "ay-report",
params: { recordid: m.id, ayatype: window.$gz.type.Widget }
});
} else {
//general report selector chosen
let res = await m.vm.$refs.reportSelector.open({
ObjectType: window.$gz.type.Widget,
selectedRowIds: [m.vm.obj.id]
});
let res = await m.vm.$refs.reportSelector.open({
ObjectType: window.$gz.type.Widget,
selectedRowIds: [m.vm.obj.id]
});
//if null for no selection
//just bail out
if (res == null) {
return;
//if null for no selection
//just bail out
if (res == null) {
return;
}
//persist last report selected
window.$gz.form.setLastReport(FORM_KEY, res);
//Now open the report viewer...
m.vm.$router.push({
name: "ay-report",
params: { recordid: res.id, ayatype: window.$gz.type.Widget }
});
}
//persist last report selected
window.$gz.form.setLastReport(FORM_KEY, res);
//Now open the report viewer...
m.vm.$router.push({
name: "ay-report",
params: { recordid: res.id, ayatype: window.$gz.type.Widget }
});
}
break;
default:
window.$gz.eventBus.$emit(
"notify-warning",
FORM_KEY + "::context click: [" + m.key + "]"
);
break;
default:
window.$gz.eventBus.$emit(
"notify-warning",
FORM_KEY + "::context click: [" + m.key + "]"
);
}
}
} catch (ex) {
console.log("Widget menu handler error handler");
window.$gz.errorHandler.handleFormError(ex, m.vm);
}
}