Skip to content
Draft
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: 4 additions & 2 deletions packages/core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ export enum CustomErrorCodes {
OAUTH_REFRESH_FAILED = 'OAUTH_REFRESH_FAILED',
// Destination has spent more than the alloted time and needs to self-terminate
SELF_TIMEOUT = 'SELF_TIMEOUT',

// Fallback error code if no other error code matches
UNKNOWN_ERROR = 'UNKNOWN_ERROR'
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
// Destination not ready to process requests. Can be used in scenarios where we want to retry because destination is still processing some events due to race condition.
// Example: In Adobe Target, if profile creation is in progress, any updateProfile calls will fail. In such cases, we can use this error code to indicate that destination is not ready yet.
DESTINATION_NOT_READY = 'DESTINATION_NOT_READY'
}

const HTTP_ERROR_CODE_MAP: Record<number, HttpErrorCodes> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestClient, IntegrationError, APIError } from '@segment/actions-core'
import { RequestClient, IntegrationError, ErrorCodes } from '@segment/actions-core'
import { StatsContext } from '@segment/actions-core/destination-kit'

function getNestedObjects(obj: { [x: string]: any }, objectPath = '', attributes: { [x: string]: string } = {}) {
Expand Down Expand Up @@ -76,7 +76,9 @@ export default class AdobeTarget {
statsContext?.statsClient.incr('actions-adobe-target.profile-not-found', 1, statsContext.tags)
}

throw new APIError(error.message, errorCode)
// TOO_EARLY error type indicates that this error is retryable error type but server is not ready yet to process the request.
// Centrifuge dosn't retry 425 so we keep the error code as 500.
throw new IntegrationError(error.message, ErrorCodes.DESTINATION_NOT_READY, errorCode)
}
}

Expand Down
Loading