or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

errors.mdfifo.mdindex.mdparser.mdtypes.md
tile.json

errors.mddocs/

Error Handling

Error Hierarchy

Error
  └── BatchProcessingError
        ├── FullBatchFailureError
        ├── SqsFifoShortCircuitError
        ├── SqsFifoMessageGroupShortCircuitError
        ├── UnexpectedBatchTypeError
        └── ParsingError

Error Types

BatchProcessingError

Base error class for all batch processing errors.

class BatchProcessingError extends Error {
  constructor(message: string);
  name: string;
}

FullBatchFailureError

Thrown when all records fail processing (unless throwOnFullBatchFailure: false).

class FullBatchFailureError extends BatchProcessingError {
  constructor(childErrors: Error[]);
  name: string;
  recordErrors: Error[];
}

Usage:

try {
  return await processPartialResponse(event, recordHandler, processor, { context });
} catch (error) {
  if (error instanceof FullBatchFailureError) {
    console.error(`All ${error.recordErrors.length} records failed`);
  }
  throw error;
}

Disable:

processPartialResponse(event, recordHandler, processor, {
  context,
  throwOnFullBatchFailure: false,
});

SqsFifoShortCircuitError

Applied to unprocessed records when FIFO processing is short-circuited.

class SqsFifoShortCircuitError extends BatchProcessingError {
  constructor();
  name: string;
}

SqsFifoMessageGroupShortCircuitError

Applied to records from a failed message group when skipGroupOnError: true.

class SqsFifoMessageGroupShortCircuitError extends BatchProcessingError {
  constructor();
  name: string;
}

UnexpectedBatchTypeError

Thrown when event doesn't contain a valid Records array.

class UnexpectedBatchTypeError extends BatchProcessingError {
  constructor();
  name: string;
}

ParsingError

Thrown when schema validation fails during parser integration.

class ParsingError extends BatchProcessingError {
  constructor(message: string);
  name: string;
}

Usage:

try {
  return await processPartialResponse(event, recordHandler, processor, { context });
} catch (error) {
  if (error instanceof ParsingError) {
    console.error('Schema validation failed:', error.message);
  }
  throw error;
}

Error Handling Patterns

Catch All Batch Errors

try {
  return await processPartialResponse(event, recordHandler, processor, { context });
} catch (error) {
  if (error instanceof BatchProcessingError) {
    console.error('Batch error:', error.name, error.message);
  }
  throw error;
}

Multiple Error Types

try {
  return await processPartialResponse(event, recordHandler, processor, { context });
} catch (error) {
  if (error instanceof FullBatchFailureError) {
    console.error(`All failed: ${error.recordErrors.length} errors`);
  } else if (error instanceof ParsingError) {
    console.error('Validation failed:', error.message);
  } else if (error instanceof UnexpectedBatchTypeError) {
    console.error('Invalid event structure');
  }
  throw error;
}

Custom Handler Errors

class ValidationError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'ValidationError';
  }
}

const recordHandler = async (record: SQSRecord): Promise<void> => {
  const payload = JSON.parse(record.body);
  if (!payload.id) throw new ValidationError('Missing id');
  // Process record
};

Response Format

Failed records are tracked in the response:

type PartialItemFailureResponse = {
  batchItemFailures: Array<{ itemIdentifier: string }>;
};

Item Identifiers:

  • SQS: Message ID
  • Kinesis: Sequence number
  • DynamoDB: Sequence number