tryError Documentation

Interface: TryErrorConfig
Interface

Defined in: [config.ts:108](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/config.ts#L108) Configuration options for tryError behavior

tryError API Documentation v0.0.1-alpha.1


tryError API Documentation / TryErrorConfig

Interface: TryErrorConfig

Defined in: config.ts:108

Configuration options for tryError behavior

Properties

captureStackTrace?

optional captureStackTrace: boolean;

Defined in: config.ts:113

Whether to capture stack traces (expensive operation)

Default

true in development, false in production;

defaultErrorType?

optional defaultErrorType: string;

Defined in: config.ts:178

Default error type for untyped errors

Default

"Error";

developmentMode?

optional developmentMode: boolean;

Defined in: config.ts:184

Enable development mode features (verbose logging, etc.)

Default

false;

environmentHandlers?

optional environmentHandlers: {
  client?: (error) => TryError;
  edge?: (error) => TryError;
  server?: (error) => TryError;
};

Defined in: config.ts:206

Environment-specific error handlers (used with runtimeDetection)

client()?

optional client: (error) => TryError;
Parameters
error

TryError

Returns

TryError

edge()?

optional edge: (error) => TryError;
Parameters
error

TryError

Returns

TryError

server()?

optional server: (error) => TryError;
Parameters
error

TryError

Returns

TryError


includeSource?

optional includeSource: boolean;

Defined in: config.ts:125

Include source location in errors

Default

true;

minimalErrors?

optional minimalErrors: boolean;

Defined in: config.ts:131

Enable minimal error mode for ultra-lightweight errors

Default

false;

onError()?

optional onError: (error) => TryError;

Defined in: config.ts:194

Global error transformation hook

Parameters

error

TryError

Returns

TryError


performance?

optional performance: PerformanceConfig;

Defined in: config.ts:215

Performance optimization configuration


runtimeDetection?

optional runtimeDetection: boolean;

Defined in: config.ts:201

Runtime environment detection for isomorphic apps (Next.js, Nuxt, etc.) When enabled, environment-specific handlers are called based on runtime detection

Default

false;

serializer()?

optional serializer: (error) => Record<string, unknown>;

Defined in: config.ts:189

Custom error serialization function

Parameters

error

TryError

Returns

Record<string, unknown>


skipContext?

optional skipContext: boolean;

Defined in: config.ts:143

Skip context processing

Default

false;

skipTimestamp?

optional skipTimestamp: boolean;

Defined in: config.ts:137

Skip timestamp generation (Date.now() calls)

Default

false;

sourceLocation?

optional sourceLocation: {
  defaultStackOffset?: number;
  format?: "full" | "file:line:column" | "file:line" | "file";
  formatter?: (file, line, column) => string;
  includeFullPath?: boolean;
};

Defined in: config.ts:148

Source location configuration

defaultStackOffset?

optional defaultStackOffset: number;

Default stack offset for source detection Useful when wrapping error creation

Default
3;

format?

optional format: "full" | "file:line:column" | "file:line" | "file";

Format for source location string

Default
"file:line:column";

formatter()?

optional formatter: (file, line, column) => string;

Custom source location formatter

Parameters
file

string

line

string

column

string

Returns

string

includeFullPath?

optional includeFullPath: boolean;

Include full file path or just filename

Default
false (just filename)

stackTraceLimit?

optional stackTraceLimit: number;

Defined in: config.ts:119

Maximum stack trace depth to capture

Default

10;