Commit fabb7fed authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

SPP error logs: specify which child failed and propagate child log

parent 671f37da
......@@ -117,8 +117,8 @@ describe("Class SPP: ", () => {
spp.calculatedParam = spp.prms.Y;
const res = spp.CalcSerie();
expect(res.vCalc).toBeUndefined();
expect(res.log.messages.length).toBe(1);
expect(res.log.messages[0].code).toBe(MessageCode.ERROR_SOMETHING_FAILED);
expect(res.log.messages.length).toBe(2);
expect(res.log.messages[0].code).toBe(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
expect(c1.result.log.messages.length).toBe(1);
expect(c1.result.log.messages[0].code).toBe(MessageCode.ERROR_NON_INTEGER_POWER_ON_NEGATIVE_NUMBER);
});
......@@ -133,8 +133,8 @@ describe("Class SPP: ", () => {
const res = spp.CalcSerie();
expect(res.vCalc).toBeUndefined();
expect(res.ok).toBe(false);
expect(res.log.messages.length).toBe(1);
expect(res.log.messages[0].code).toBe(MessageCode.ERROR_SOMETHING_FAILED);
expect(res.log.messages.length).toBe(2);
expect(res.log.messages[0].code).toBe(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
expect(c2.result.log.messages.length).toBe(1);
expect(c2.result.log.messages[0].code).toBe(MessageCode.ERROR_NON_INTEGER_POWER_ON_NEGATIVE_NUMBER);
});
......
......@@ -72,7 +72,10 @@ export class SPP extends Nub {
if (cRes.ok) {
vPartielle += cRes.vCalc;
} else {
this.result.log.add(new Message(MessageCode.ERROR_SOMETHING_FAILED));
const m = new Message(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
m.extraVar.number = String(c.findPositionInParent() + 1); // String to avoid decimals
this.result.log.add(m);
this.result.log.addLog(cRes.log);
return this.result;
}
}
......@@ -86,7 +89,10 @@ export class SPP extends Nub {
if (cRes.ok) {
vPartielle *= cRes.vCalc;
} else {
this.result.log.add(new Message(MessageCode.ERROR_SOMETHING_FAILED));
const m = new Message(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
m.extraVar.number = String(c.findPositionInParent() + 1); // String to avoid decimals
this.result.log.add(m);
this.result.log.addLog(cRes.log);
return this.result;
}
}
......@@ -127,7 +133,11 @@ export class SPP extends Nub {
if (cRes.ok) {
v += cRes.vCalc;
} else {
return new Result(new Message(MessageCode.ERROR_SOMETHING_FAILED));
const m = new Message(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
m.extraVar.number = String(c.findPositionInParent() + 1); // String to avoid decimals
this.result.log.add(m);
this.result.log.addLog(cRes.log);
return this.result;
}
}
} else if (this.operation === SPPOperation.PRODUCT) {
......@@ -137,7 +147,11 @@ export class SPP extends Nub {
if (cRes.ok) {
v *= cRes.vCalc;
} else {
return new Result(new Message(MessageCode.ERROR_SOMETHING_FAILED));
const m = new Message(MessageCode.ERROR_SOMETHING_FAILED_IN_CHILD);
m.extraVar.number = String(c.findPositionInParent() + 1); // String to avoid decimals
this.result.log.add(m);
this.result.log.addLog(cRes.log);
return this.result;
}
}
}
......
......@@ -5,7 +5,7 @@ export enum MessageCode {
ERROR_OK,
/** generic error stating that something triggered a fatal error leading to an undefined vCalc */
ERROR_SOMETHING_FAILED,
ERROR_SOMETHING_FAILED_IN_CHILD,
/** abstract showing number of error messages encountered in an iterative calculation */
WARNING_ERRORS_ABSTRACT,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment