From 2879fb8cee4664d3eec16dd9f59b87aafaeee14a Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 16 Jun 2020 15:03:10 +0000 Subject: [PATCH] fix(core): update --- ts/typedrequest.classes.typedhandler.ts | 24 +++++++++++++++++-- ts/typedrequest.classes.typedresponseerror.ts | 10 ++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 ts/typedrequest.classes.typedresponseerror.ts diff --git a/ts/typedrequest.classes.typedhandler.ts b/ts/typedrequest.classes.typedhandler.ts index 0c22010..93a99ca 100644 --- a/ts/typedrequest.classes.typedhandler.ts +++ b/ts/typedrequest.classes.typedhandler.ts @@ -1,4 +1,5 @@ import * as plugins from './typedrequest.plugins'; +import { TypedResponseError } from './typedrequest.classes.typedresponseerror'; type THandlerFunction = ( requestArg: T['request'] @@ -26,8 +27,27 @@ export class TypedHandler { + if (e instanceof TypedResponseError) { + typedResponseError = e; + } else { + throw e; + } + }); + + if (typedResponseError) { + typedRequestArg.error = { + text: typedResponseError.errorText, + data: typedResponseError.errorData + }; + } + + if (response) { + typedRequestArg.response = response; + } + + return typedRequestArg; } } diff --git a/ts/typedrequest.classes.typedresponseerror.ts b/ts/typedrequest.classes.typedresponseerror.ts new file mode 100644 index 0000000..14df603 --- /dev/null +++ b/ts/typedrequest.classes.typedresponseerror.ts @@ -0,0 +1,10 @@ +import * as plugins from './typedrequest.plugins'; + +export class TypedResponseError { + public errorText: string; + public errorData: any; + constructor(errorTextArg: string, errorDataArg: any) { + this.errorText = errorTextArg; + this.errorData = errorDataArg; + } +} \ No newline at end of file