-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[connectors] Cast known Zendesk errors (#8917)
* add a few error types and checks * add `ZendeskCastKnownErrorsInterceptor` * add the interceptor to the worker * fix: remove redundant checks for known errors * fix: fix the error type of expired cursor errors
- Loading branch information
1 parent
237ee4f
commit 5406742
Showing
6 changed files
with
87 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
connectors/src/connectors/zendesk/temporal/cast_known_errors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { | ||
ActivityExecuteInput, | ||
ActivityInboundCallsInterceptor, | ||
Next, | ||
} from "@temporalio/worker"; | ||
|
||
import { | ||
isNodeZendeskForbiddenError, | ||
isZendeskEpipeError, | ||
isZendeskExpiredCursorError, | ||
} from "@connectors/connectors/zendesk/lib/errors"; | ||
import { | ||
DustConnectorWorkflowError, | ||
ExternalOAuthTokenError, | ||
ProviderWorkflowError, | ||
} from "@connectors/lib/error"; | ||
|
||
export class ZendeskCastKnownErrorsInterceptor | ||
implements ActivityInboundCallsInterceptor | ||
{ | ||
async execute( | ||
input: ActivityExecuteInput, | ||
next: Next<ActivityInboundCallsInterceptor, "execute"> | ||
): Promise<unknown> { | ||
try { | ||
return await next(input); | ||
} catch (err: unknown) { | ||
if (isNodeZendeskForbiddenError(err)) { | ||
throw new ExternalOAuthTokenError(err); | ||
} else if (isZendeskExpiredCursorError(err)) { | ||
throw new DustConnectorWorkflowError( | ||
"Cursor expired", | ||
"unhandled_internal_activity_error", | ||
err | ||
); | ||
} else if (isZendeskEpipeError(err)) { | ||
throw new ProviderWorkflowError( | ||
"zendesk", | ||
"EPIPE", | ||
"transient_upstream_activity_error", | ||
err | ||
); | ||
} | ||
|
||
throw err; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters