UNPKG

@cumulus/errors

Version:
125 lines 7.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnmetRequirementsError = exports.IndexExistsError = exports.PostgresUpdateFailed = exports.PostgresValidationError = exports.ValidationError = exports.UnparsableFileLocationError = exports.UnmatchedRegexError = exports.UnexpectedFileSize = exports.RecordDoesNotExist = exports.RecordAlreadyMigrated = exports.ProviderNotFound = exports.PDRParsingError = exports.MissingS3FileError = exports.MissingRequiredEnvVarError = exports.MissingRequiredEnvVar = exports.MissingRequiredArgument = exports.MismatchPdrCollection = exports.InvalidRegexError = exports.InvalidChecksum = exports.InvalidArgument = exports.HostNotFound = exports.GranuleFileWriteError = exports.GranuleNotPublished = exports.FTPError = exports.FileNotFound = exports.EcsStartTaskError = exports.DuplicateFile = exports.DeletePublishedGranule = exports.CumulusMessageError = exports.ConnectionTimeout = exports.ApiCollisionError = exports.MissingBucketMap = exports.CMRInternalError = exports.CMRMetaFileNotFound = exports.XmlMetaFileNotFound = exports.RemoteResourceError = exports.ResourcesLockedError = exports.IncompleteError = exports.NotNeededError = exports.WorkflowError = exports.isConditionalCheckException = exports.isWorkflowError = exports.isThrottlingException = exports.ThrottlingException = exports.createErrorType = void 0; /** * Creates a new error type with the given name and parent class. Sets up * boilerplate necessary to successfully subclass Error and preserve stack trace * @param name - The name of the error type * @param ParentType - The error that serves as the parent * @returns The new type */ const createErrorType = (name, ParentType = Error) => (class extends ParentType { constructor(message) { super(message); this.name = name; Error.captureStackTrace(this, this.constructor); } }); exports.createErrorType = createErrorType; class ThrottlingException extends Error { constructor() { super('ThrottlingException'); this.name = 'ThrottlingException'; this.code = 'ThrottlingException'; Error.captureStackTrace(this, this.constructor); } } exports.ThrottlingException = ThrottlingException; /** * Test to see if a given exception is a Throttling Exception. */ const isThrottlingException = (err) => err.name === 'ThrottlingException' || err.code === 'ThrottlingException'; exports.isThrottlingException = isThrottlingException; /** * Returns true if the error is a resource error. */ const isWorkflowError = (error) => error.name.includes('WorkflowError'); exports.isWorkflowError = isWorkflowError; /** * Returns true if the error is a DynamoDB conditional check exception. */ const isConditionalCheckException = (error) => error.name === 'ConditionalCheckFailedException'; exports.isConditionalCheckException = isConditionalCheckException; /** * WorkflowError should be bubbled out to the overall workflow in the 'exception' field, rather than * being thrown and causting an immediate failure */ exports.WorkflowError = (0, exports.createErrorType)('WorkflowError'); /** * NotNeededError indicates that execution was not completed because it was unnecessary. The * workflow should therefore terminate but be considered successful */ exports.NotNeededError = (0, exports.createErrorType)('NotNeededWorkflowError', exports.WorkflowError); /** * IncompleteError indicates that the execution was partially successful and can be re-executed to * make further progress. This may happen, for instance, if an execution timeout stops progress */ exports.IncompleteError = (0, exports.createErrorType)('IncompleteWorkflowError', exports.WorkflowError); /** * ResourcesLockedError indicates that the execution is unable to proceed due to resources being * tied up in other executions. Execution may be retried after resources free up */ exports.ResourcesLockedError = (0, exports.createErrorType)('ResourcesLockedWorkflowError', exports.WorkflowError); /** * RemoteResourceError indicates that a required remote resource could not be fetched or otherwise * used */ exports.RemoteResourceError = (0, exports.createErrorType)('RemoteResourceError'); /** * The error object for when the xml file path is not provided */ exports.XmlMetaFileNotFound = (0, exports.createErrorType)('XmlMetaFileNotFound'); /** * No CMR metadata file was present. */ exports.CMRMetaFileNotFound = (0, exports.createErrorType)('CMRMetaFileNotFound'); /** * CMR returned an internal server error */ exports.CMRInternalError = (0, exports.createErrorType)('CMRInternalError'); /** * Distribution bucket map is missing a configured value for a distribution bucket */ exports.MissingBucketMap = (0, exports.createErrorType)('MissingBucketMap'); /** * The provider info is missing error */ exports.ApiCollisionError = (0, exports.createErrorType)('ApiCollisionError'); exports.ConnectionTimeout = (0, exports.createErrorType)('ConnectionTimeout'); exports.CumulusMessageError = (0, exports.createErrorType)('CumulusMessageError'); exports.DeletePublishedGranule = (0, exports.createErrorType)('DeletePublishedGranule'); exports.DuplicateFile = (0, exports.createErrorType)('DuplicateFile'); exports.EcsStartTaskError = (0, exports.createErrorType)('EcsStartTaskError'); exports.FileNotFound = (0, exports.createErrorType)('FileNotFound'); exports.FTPError = (0, exports.createErrorType)('FTPError'); exports.GranuleNotPublished = (0, exports.createErrorType)('GranuleNotPublished'); exports.GranuleFileWriteError = (0, exports.createErrorType)('GranuleFileWriteError'); exports.HostNotFound = (0, exports.createErrorType)('HostNotFound'); exports.InvalidArgument = (0, exports.createErrorType)('InvalidArgument'); exports.InvalidChecksum = (0, exports.createErrorType)('InvalidChecksum'); exports.InvalidRegexError = (0, exports.createErrorType)('InvalidRegexError'); exports.MismatchPdrCollection = (0, exports.createErrorType)('MismatchPdrCollection'); exports.MissingRequiredArgument = (0, exports.createErrorType)('MissingRequiredArgument'); exports.MissingRequiredEnvVar = (0, exports.createErrorType)('MissingRequiredEnvVar'); exports.MissingRequiredEnvVarError = (0, exports.createErrorType)('MissingRequiredEnvVarError'); exports.MissingS3FileError = (0, exports.createErrorType)('MissingS3FileError'); exports.PDRParsingError = (0, exports.createErrorType)('PDRParsingError'); exports.ProviderNotFound = (0, exports.createErrorType)('ProviderNotFound'); exports.RecordAlreadyMigrated = (0, exports.createErrorType)('RecordAlreadyMigrated'); exports.RecordDoesNotExist = (0, exports.createErrorType)('RecordDoesNotExist'); exports.UnexpectedFileSize = (0, exports.createErrorType)('UnexpectedFileSize'); exports.UnmatchedRegexError = (0, exports.createErrorType)('UnmatchedRegexError'); exports.UnparsableFileLocationError = (0, exports.createErrorType)('UnparsableFileLocationError'); exports.ValidationError = (0, exports.createErrorType)('ValidationError'); class PostgresValidationError extends exports.ValidationError { constructor(message) { super(message); this.name = 'PostgresValidationError'; Error.captureStackTrace(this, this.constructor); } } exports.PostgresValidationError = PostgresValidationError; exports.PostgresUpdateFailed = (0, exports.createErrorType)('PostgresUpdateFailed'); exports.IndexExistsError = (0, exports.createErrorType)('IndexExistsError'); exports.UnmetRequirementsError = (0, exports.createErrorType)('UnmetRequirementsError'); //# sourceMappingURL=index.js.map