Skip to content

Commit

Permalink
[patch] Add missing properties to VoucherifyError class (#190)
Browse files Browse the repository at this point in the history
* patch - add missing 'related_object_ids', 'related_object_type' and 'related_object_total' properties to 'VoucherifyError' class. Those properties are returned from API in case of 'resource_in_use' error

* Add CHANGESET file
  • Loading branch information
darekg11 authored Feb 27, 2023
1 parent 127f4d9 commit 48a46b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-dragons-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@voucherify/sdk': patch
---

Add missing 'related_object_ids', 'related_object_type' and 'related_object_total' properties to 'VoucherifyError' class. Those properties are returned fmor API in case of 'resource_in_ise' error
6 changes: 6 additions & 0 deletions packages/sdk/src/VoucherifyError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export class VoucherifyError extends Error {
public request_id?: string
public resource_id?: string
public resource_type?: string
public related_object_ids?: string[]
public related_object_type?: string
public related_object_total?: number
public cause?: AxiosError

constructor(statusCode: number, body?: unknown, axiosError?: AxiosError) {
Expand All @@ -25,6 +28,9 @@ export class VoucherifyError extends Error {
this.request_id = (<any>body).request_id
this.resource_id = (<any>body).resource_id
this.resource_type = (<any>body).resource_type
this.related_object_ids = (<any>body).related_object_ids
this.related_object_type = (<any>body).related_object_type
this.related_object_total = (<any>body).related_object_total
this.cause = axiosError
}
}
Expand Down

0 comments on commit 48a46b9

Please sign in to comment.