UNPKG

@aws-lambda-powertools/batch

Version:

The batch processing package for the Powertools for AWS Lambda (TypeScript) library.

71 lines (70 loc) 2.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParsingError = exports.UnexpectedBatchTypeError = exports.SqsFifoMessageGroupShortCircuitError = exports.SqsFifoShortCircuitError = exports.FullBatchFailureError = exports.BatchProcessingError = void 0; const constants_js_1 = require("./constants.js"); /** * Base error thrown by the Batch Processing utility */ class BatchProcessingError extends Error { constructor(message) { super(message); this.name = 'BatchProcessingError'; } } exports.BatchProcessingError = BatchProcessingError; /** * Error thrown by the Batch Processing utility when all batch records failed to be processed */ class FullBatchFailureError extends BatchProcessingError { recordErrors; constructor(childErrors) { super('All records failed processing. See individual errors below.'); this.recordErrors = childErrors; this.name = 'FullBatchFailureError'; } } exports.FullBatchFailureError = FullBatchFailureError; /** * Error thrown by the Batch Processing utility when a SQS FIFO queue is short-circuited. * This happens when a record fails processing and the remaining records are not processed * to avoid out-of-order delivery. */ class SqsFifoShortCircuitError extends BatchProcessingError { constructor() { super('A previous record failed processing. The remaining records were not processed to avoid out-of-order delivery.'); this.name = 'SqsFifoShortCircuitError'; } } exports.SqsFifoShortCircuitError = SqsFifoShortCircuitError; /** * Error thrown by the Batch Processing utility when a previous record from * SQS FIFO queue message group fails processing. */ class SqsFifoMessageGroupShortCircuitError extends BatchProcessingError { constructor() { super('A previous record from this message group failed processing'); this.name = 'SqsFifoMessageGroupShortCircuitError'; } } exports.SqsFifoMessageGroupShortCircuitError = SqsFifoMessageGroupShortCircuitError; /** * Error thrown by the Batch Processing utility when a partial processor receives an unexpected * batch type. */ class UnexpectedBatchTypeError extends BatchProcessingError { constructor() { super(`Unexpected batch type. Possible values are: ${Object.values(constants_js_1.EventType).join(', ')}`); this.name = 'UnexpectedBatchTypeError'; } } exports.UnexpectedBatchTypeError = UnexpectedBatchTypeError; /** * Error thrown by the Batch Processing utility when a record fails to be parsed. */ class ParsingError extends BatchProcessingError { constructor(message) { super(message); this.name = 'ParsingError'; } } exports.ParsingError = ParsingError;