Skip to content
3 min read · 579 words

Class: BaseException

Defined in: lib/classes/base_exception.ts:16

Base class for all structured exceptions in the ADK.

Remarks

Subclasses should declare static code, status, fatal, and optionally help to avoid repeating those values on every instance. Instance-level options always take precedence over static defaults, so a single exception class can still be thrown with per-site overrides when needed.

The runtime cross-realm guard is inlined here rather than imported from ../utils/guards to break a circular-import chain: guards depends on validation, which extends BaseException. Importing the shared isInstanceOf helper into this file would create a load-order cycle that leaves BaseException undefined when ValidationException extends BaseException evaluates.

Extends

  • Error

Extended by

Constructors

Constructor

ts
new BaseException(message?: string, options?: ErrorOptions & {
  code?: string;
  fatal?: boolean;
  status?: number;
}): BaseException;

Defined in: lib/classes/base_exception.ts:96

Parameters

ParameterTypeDescription
message?stringHuman-readable error message. Falls back to the static message on the subclass if omitted.
options?ErrorOptions & { code?: string; fatal?: boolean; status?: number; }Standard ErrorOptions extended with code, status, and fatal overrides. Static defaults on the subclass are used when these are absent.

Returns

BaseException

Overrides

ts
Error.constructor;

Properties

PropertyModifierTypeDescriptionOverridesDefined in
code?publicstringMachine-readable error code for narrowing exception-handling logic.-lib/classes/base_exception.ts:78
fatal?publicbooleanWhen true, the ADK treats this error as unrecoverable and should halt the agent loop.-lib/classes/base_exception.ts:88
help?publicstringHuman-readable guidance for resolving or reporting this error.-lib/classes/base_exception.ts:73
namepublicstringName of the class that raised the exception.Error.namelib/classes/base_exception.ts:68
status?publicnumberHTTP status code associated with this error.-lib/classes/base_exception.ts:83
code?staticstringDefault machine-readable error code inherited by all instances.-lib/classes/base_exception.ts:51
fatal?staticbooleanWhether exceptions of this class are fatal by default.-lib/classes/base_exception.ts:59
help?staticstringDefault help text inherited by all instances unless overridden at the throw site.-lib/classes/base_exception.ts:47
message?staticstringDefault message used when no message is supplied to the constructor.-lib/classes/base_exception.ts:63
status?staticnumberDefault HTTP status code inherited by all instances.-lib/classes/base_exception.ts:55

Accessors

[toStringTag]

Get Signature

ts
get toStringTag: string;

Defined in: lib/classes/base_exception.ts:130

Returns

string

Methods

toString()

ts
toString(): string;

Defined in: lib/classes/base_exception.ts:134

Returns a string representation of an object.

Returns

string


isBaseException()

ts
static isBaseException(value: unknown): value is BaseException;

Defined in: lib/classes/base_exception.ts:29

Returns true if value is a BaseException instance.

Parameters

ParameterTypeDescription
valueunknownThe value to test.

Returns

value is BaseException

true when value is a BaseException instance.

Remarks

Performs cross-realm-safe detection: tries instanceof, then Symbol.hasInstance, then constructor-name comparison. The ADK does not export the BaseException class itself as a constructable value — use this guard plus the BaseException type for runtime detection and TypeScript narrowing.