Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/__tests__/linkup-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LinkupPaymentRequiredError,
LinkupTaskNotFoundError,
LinkupTasksQueueLimitExceededError,
LinkupTaskTypeNotSupportedError,
LinkupTooManyRequestsError,
LinkupUnknownError,
} from '../errors';
Expand Down Expand Up @@ -839,9 +840,8 @@ describe('LinkupClient', () => {
},
{
description: '403 TASK_TYPE_NOT_SUPPORTED',
ErrorClass: LinkupUnknownError,
expectedMessage:
'Unsupported task type: Extract tasks are not enabled for this organization.',
ErrorClass: LinkupTaskTypeNotSupportedError,
expectedMessage: 'Extract tasks are not enabled for this organization.',
input: {
error: {
code: 'TASK_TYPE_NOT_SUPPORTED',
Expand Down
13 changes: 13 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ export class LinkupTaskNotFoundError extends LinkupError {
}
}

// Task type not supported error, raised when the Linkup API returns a 403 status code.
// It is returned when a task type is not enabled for the current organization.
export class LinkupTaskTypeNotSupportedError extends LinkupError {
constructor(message?: string) {
super(message);
this.name = LinkupTaskTypeNotSupportedError.name;

if ('captureStackTrace' in Error) {
Error.captureStackTrace(this, LinkupTaskTypeNotSupportedError);
}
}
}

// Insufficient credit error, raised when the Linkup API returns a 429 status code.
// It is returned when you have run out of credits.
export class LinkupInsufficientCreditError extends LinkupError {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/refine-error.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LinkupPaymentRequiredError,
LinkupTaskNotFoundError,
LinkupTasksQueueLimitExceededError,
LinkupTaskTypeNotSupportedError,
LinkupTooManyRequestsError,
LinkupUnknownError,
} from '../errors';
Expand Down Expand Up @@ -59,7 +60,7 @@ export const refineError = (e: LinkupApiError): LinkupError => {
case 403:
switch (code) {
case 'TASK_TYPE_NOT_SUPPORTED':
return new LinkupUnknownError(`Unsupported task type: ${message}`);
return new LinkupTaskTypeNotSupportedError(message);
default:
return new LinkupAuthenticationError(message);
}
Expand Down