pg-transactional-outbox
Version:
A PostgreSQL based transactional outbox and inbox pattern implementation to support exactly once message processing (with at least once message delivery).
27 lines • 1.86 kB
TypeScript
import { TransactionalMessage } from '../message/transactional-message';
export type ErrorCode = 'DB_ERROR' | 'MESSAGE_HANDLING_FAILED' | 'MESSAGE_ERROR_HANDLING_FAILED' | 'GIVING_UP_MESSAGE_HANDLING' | 'POISONOUS_MESSAGE' | 'CONFLICTING_MESSAGE_HANDLERS' | 'NO_MESSAGE_HANDLER_REGISTERED' | 'LSN_ALREADY_PROCESSED' | 'LSN_NOT_PROCESSING' | 'LISTENER_STOPPED' | 'TIMEOUT' | 'MESSAGE_STORAGE_FAILED' | 'BATCH_PROCESSING_ERROR' | 'MESSAGE_CLEANUP_ERROR';
export interface ExtendedError extends Error {
errorCode: ErrorCode;
innerError?: Error;
}
/** An error that was raised from the transactional outbox/inbox library. Includes an error code. */
export declare class TransactionalOutboxInboxError extends Error implements ExtendedError {
errorCode: ErrorCode;
innerError?: Error;
constructor(message: string, errorCode: ErrorCode, innerError?: unknown);
}
/** An error that was raised when handling an outbox/inbox message. */
export declare class MessageError<T extends TransactionalMessage> extends TransactionalOutboxInboxError {
messageObject: T;
constructor(message: string, errorCode: ErrorCode, messageObject: T, innerError?: unknown);
}
/**
* Returns the error as verified Error object or wraps the input as
* ExtendedError with error code and potential innerError.
* @param error The error variable to check
* @param fallbackErrorCode The error code to use if the message is not already a TransactionalOutboxInboxError.
* @param message The message object to use if the message is not a TransactionalOutboxInboxError.
* @returns The error if the input was already an error otherwise a wrapped error. Enriched with the error code property.
*/
export declare const ensureExtendedError: (error: unknown, fallbackErrorCode: ErrorCode, message?: TransactionalMessage) => ExtendedError;
//# sourceMappingURL=error.d.ts.map