Skip to content

Commit 1589b18

Browse files
committed
Expand ApiError object
1 parent 1702cda commit 1589b18

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/httpClient/httpClientException.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
*/
1919

2020
import { IncomingHttpHeaders } from "http";
21+
import { ApiError } from "../typings/apiError";
2122

2223
interface ExceptionInterface {
2324
message: string;
2425
statusCode?: number;
2526
errorCode?: string;
2627
responseHeaders?: IncomingHttpHeaders;
2728
responseBody?: string;
29+
apiError?: ApiError; // model of the error returned by the API
2830
}
2931

3032
class HttpClientException extends Error {
@@ -33,6 +35,7 @@ class HttpClientException extends Error {
3335
public responseHeaders?: IncomingHttpHeaders;
3436
public readonly name: string;
3537
public responseBody?: string;
38+
public apiError?: ApiError;
3639

3740
public constructor(props: ExceptionInterface) {
3841
super(props.message);
@@ -44,6 +47,7 @@ class HttpClientException extends Error {
4447
if (props.responseBody) this.responseBody = props.responseBody;
4548
if (props.errorCode) this.errorCode = props.errorCode;
4649
if (props.statusCode) this.statusCode = props.statusCode;
50+
if (props.apiError) this.apiError = props.apiError;
4751
}
4852
}
4953

src/typings/apiError.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,21 @@
1717
* See the LICENSE file for more info.
1818
*/
1919

20-
// Generated using typescript-generator version 2.14.505 on 2019-06-04 08:51:10.
21-
20+
// ApiError interface to model Adyen API errors
21+
// The interface is an union of the 2 different error models used by Adyen APIs:
22+
// RestServiceError (based on RFC 7807)
23+
// ServiceError (based on the original Adyen error model).
2224
export interface ApiError {
2325
status?: number;
2426
errorCode?: string;
2527
message?: string;
2628
errorType?: string;
2729
pspReference?: string;
30+
31+
detail?: string
32+
instance?: string;
33+
invalidFields?: Array<string>;
34+
requestId?: string;
35+
title?: string;
36+
type?: string;
2837
}

0 commit comments

Comments
 (0)