tryError Documentation

Interface: AmountError\<T\>
Interface

Defined in: [factories.ts:274](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/factories.ts#L274) Base type for errors involving monetary amounts (payments, billing, etc.) Provides consistent fields for financial operations across different domains.

tryError API Documentation v0.0.1-alpha.1


tryError API Documentation / AmountError

Interface: AmountError<T>

Defined in: factories.ts:274

Base type for errors involving monetary amounts (payments, billing, etc.)

Provides consistent fields for financial operations across different domains.

Example

interface PaymentError
  extends AmountError<"CardDeclined" | "InsufficientFunds"> {
  readonly transactionId: string;
}

const error: PaymentError = {
  ...createError({ type: "CardDeclined", message: "Card was declined" }),
  amount: 99.99,
  currency: "USD",
  transactionId: "tx_123",
};

Extends

Type Parameters

T

T extends string

Properties

amount

readonly amount: number;

Defined in: factories.ts:278

The monetary amount involved in the error


cause?

readonly optional cause: unknown;

Defined in: types.ts:50

The original error or thrown value that caused this error

Inherited from

TryError.cause


context?

readonly optional context: Record<string, unknown>;

Defined in: types.ts:45

Additional context data for debugging

Inherited from

TryError.context


currency

readonly currency: string;

Defined in: factories.ts:283

The currency code (ISO 4217)


message

readonly message: string;

Defined in: types.ts:25

Human-readable error message

Inherited from

TryError.message


source

readonly source: string;

Defined in: types.ts:35

Source location where the error occurred (file:line:column)

Inherited from

TryError.source


stack?

readonly optional stack: string;

Defined in: types.ts:30

Stack trace if available (may be stripped in production)

Inherited from

TryError.stack


timestamp

readonly timestamp: number;

Defined in: types.ts:40

Timestamp when the error was created

Inherited from

TryError.timestamp


type

readonly type: T;

Defined in: types.ts:20

The type of error - used for discriminated unions

Inherited from

TryError.type