Skip to content
3 min read · 539 words

Class: BaseException

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;

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

PropertyModifierTypeDescriptionOverrides
code?publicstringMachine-readable error code for narrowing exception-handling logic.-
fatal?publicbooleanWhen true, the ADK treats this error as unrecoverable and should halt the agent loop.-
help?publicstringHuman-readable guidance for resolving or reporting this error.-
namepublicstringName of the class that raised the exception.Error.name
status?publicnumberHTTP status code associated with this error.-
code?staticstringDefault machine-readable error code inherited by all instances.-
fatal?staticbooleanWhether exceptions of this class are fatal by default.-
help?staticstringDefault help text inherited by all instances unless overridden at the throw site.-
message?staticstringDefault message used when no message is supplied to the constructor.-
status?staticnumberDefault HTTP status code inherited by all instances.-

Accessors

[toStringTag]

Get Signature

ts
get toStringTag: string;
Returns

string

Methods

toString()

ts
toString(): string;

Returns a string representation of an object.

Returns

string


isBaseException()

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

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.