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