Skip to content

Commit

Permalink
fix HubSpotAuthError
Browse files Browse the repository at this point in the history
  • Loading branch information
camden11 committed Dec 12, 2023
1 parent 84b5caf commit b214c0d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions models/HubSpotAuthError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ export class HubSpotAuthError extends Error {
status?: number;
category?: string;
subCategory?: string;
constructor(message: string, { cause = {} }: { cause?: AxiosError }) {
constructor(
message: string,
{
cause = {},
}: {
cause?: Partial<AxiosError<{ category?: string; subCategory?: string }>>;
}
) {
super(message);
this.name = 'HubSpotAuthError';
this.status = cause.status;
this.category = cause?.response?.body?.category || undefined;
this.category = cause?.response?.data?.category || undefined;
this.subCategory =
(cause.response &&
cause.response.body &&
cause.response.body.subCategory) ||
cause.response.data &&
cause.response.data.subCategory) ||
undefined;
}
}

0 comments on commit b214c0d

Please sign in to comment.