This commit is contained in:
2021-04-16 22:39:00 +00:00
parent 5783882c02
commit b8453f0aec
2 changed files with 62 additions and 43 deletions

View File

@@ -110,7 +110,13 @@ todo: remove widget now? Back and front (comment out obvs not remove entirely)
## SERVER MISC ITEMS
todo: errors are inconsistent some use "error" some use "code" to mean the same thing
this is likely becuase "code" is used in the outer wrapper and "error" is used in the individual "details" validation errors
however it would be much cleaner if it was the same thing at all levels
Settle on "Code" only, change "error" to "code"
some things are producing {message:"blah",target:"blah",error:"blah"}
controller apierror
and validation errors are : {message:"blah", target:"blah", code:"blah"}
todo: server boot log should show exact .net framework version in use, currently shows nothing so if there is a bug fix release or something we'd not know for support
todo: reconsider "DispatchFull" and "DispatchLimited" roles should be renamed to "ServiceFull" and "ServiceLimited" to match other roles and intent

View File

@@ -862,52 +862,66 @@ function handleSaveError(e) {
this.saveResult.errors.push(e);
}
function errorTargetFromSaveResult(r, t) {
//no particular target
//or not a woitem tree error (header)
if (r.itemUid == null || t == null || t == "generalerror") {
return t;
}
let woitemindex = this.obj.items.findIndex(z => z.uid == r.itemUid);
if (woitemindex == -1) {
return null;
}
if (r.childKey == null || r.childUid == null) {
return `Items[${woitemindex}].${t}`;
}
let childindex = this.obj.items[woitemindex][r.childKey].findIndex(
z => z.uid == r.childUid
);
if (childindex == -1) {
return null;
}
return `Items[${woitemindex}].${r.childKey}[${childindex}].${t}`;
}
function formErrorFromSaveResult() {
//digest saveresult and compile into standard form error and return
/**
* {
error: res.error,
itemUid: item.uid, //uid of item
childKey: "scheduledUsers",
childUid: i //uid of child item will be located later as index
}
*
*/
let ret = {
error: {
code: "2200", //todo: maybe an alternate error code and message indicating a package of errors (envelope?)
details: [],
message: "ErrorAPI2200"
}
};
this.saveResult.errors.forEach(z => {
z.error.details.forEach(x => {
let target = errorTargetFromSaveResult(z, x.target);
if (target != null) {
ret.error.details.push({
message: x.message,
error: x.error,
target: target
});
}
});
});
/*
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity`
{
"fatal": false,
"error": true,
"header": null,
"states": [],
"items": [
{
"e": {
"code": "2200",
"details": [
{
"message": "SAVE TEST ERROR",
"target": "Notes",
"error": "2203"
}
],
"message": "ErrorAPI2200"
},
"objectIndex": 2
}
],
"scheduledUsers": [
{
"e": {
"code": "2200",
"details": [
{
"message": "◈◈ TEST SAVE ERROR ◈◈",
"target": "EstimatedQuantity",
"error": "2203"
}
],
"message": "ErrorAPI2200"
},
"objectIndex": 0,
"woItemIndex": 3
}
]
}
DESTINATION FORMAT EXAMPLE:
@@ -979,7 +993,6 @@ function formErrorFromSaveResult() {
//iterate saveresult errors and hydrate into a displayable error as expected
//(deal with translate uid's to woitem indexes that still exist)
////set Target properly as requried and push error into the error collection
// this.saveResult.errors;
}
/////////////////////////////