FIx appendErrorToOutput()
overwriting warnings instead of appending
This commit is contained in:
parent
818bb7e37a
commit
ca1df5ee71
@ -68,13 +68,31 @@ export class HttpResponseUtil
|
|||||||
return this.getBody([]);
|
return this.getBody([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an error into the 'warnings' array of the client response message
|
||||||
|
* @param output IItemEventRouterResponse
|
||||||
|
* @param message Error message
|
||||||
|
* @param errorCode Error code
|
||||||
|
* @returns IItemEventRouterResponse
|
||||||
|
*/
|
||||||
public appendErrorToOutput(
|
public appendErrorToOutput(
|
||||||
output: IItemEventRouterResponse,
|
output: IItemEventRouterResponse,
|
||||||
message = this.localisationService.getText("http-unknown_error"),
|
message = this.localisationService.getText("http-unknown_error"),
|
||||||
errorCode = BackendErrorCodes.NONE,
|
errorCode = BackendErrorCodes.NONE,
|
||||||
): IItemEventRouterResponse
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
output.warnings = [{ index: 0, errmsg: message, code: errorCode.toString() }];
|
if (output.warnings?.length > 0)
|
||||||
|
{
|
||||||
|
output.warnings.push({
|
||||||
|
index: output.warnings?.length - 1,
|
||||||
|
errmsg: message,
|
||||||
|
code: errorCode.toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output.warnings = [{ index: 0, errmsg: message, code: errorCode.toString() }];
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user