Skip to main content

Class: AgentOSServiceError

Defined in: packages/agentos/src/api/AgentOS.ts:227

AgentOSServiceError

Description

Custom error class for errors specifically originating from the AgentOS service facade. This class provides a standardized way to represent errors encountered within the AgentOS class, inheriting common error properties from GMIError and setting a distinct error name.

Extends

  • GMIError

Constructors

Constructor

new AgentOSServiceError(message, code, details?, componentOrigin?): AgentOSServiceError

Defined in: packages/agentos/src/api/AgentOS.ts:248

Creates an instance of AgentOSServiceError.

Parameters

message

string

A human-readable description of the error.

code

string

A specific error code, typically from GMIErrorCode, identifying the nature of the error.

details?

any

Optional. Additional structured details or the underlying error object that caused this service error.

componentOrigin?

string

Optional. The name of the component or sub-module within AgentOS where the error originated or was detected. This helps in pinpointing the error's source.

Returns

AgentOSServiceError

Overrides

GMIError.constructor

Properties

cause?

readonly optional cause: unknown

Defined in: packages/agentos/src/utils/errors.ts:147

Inherited from

GMIError.cause


code

readonly code: string

Defined in: packages/agentos/src/utils/errors.ts:142

Inherited from

GMIManagerError.code


component?

readonly optional component: string

Defined in: packages/agentos/src/utils/errors.ts:144

Inherited from

GMIError.component


details?

readonly optional details: any

Defined in: packages/agentos/src/utils/errors.ts:143

Inherited from

GMIError.details


httpStatusCode?

readonly optional httpStatusCode: number

Defined in: packages/agentos/src/utils/errors.ts:146

Inherited from

GMIError.httpStatusCode


message

message: string

Defined in: apps/agentos-live-docs/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

GMIError.message


name

readonly name: string = 'AgentOSServiceError'

Defined in: packages/agentos/src/api/AgentOS.ts:235

Specifies the name of the error class, used for identification.

Overrides

GMIError.name


stack?

optional stack: string

Defined in: apps/agentos-live-docs/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

GMIError.stack


timestamp

readonly timestamp: string

Defined in: packages/agentos/src/utils/errors.ts:145

Inherited from

GMIError.timestamp


stackTraceLimit

static stackTraceLimit: number

Defined in: packages/agentos/node_modules/@types/node/globals.d.ts:68

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from

GMIError.stackTraceLimit

Methods

getHttpStatusCode()

getHttpStatusCode(): number

Defined in: packages/agentos/src/utils/errors.ts:168

Returns

number

Inherited from

GMIError.getHttpStatusCode


getUserFriendlyMessage()

getUserFriendlyMessage(): string

Defined in: packages/agentos/src/utils/errors.ts:176

Returns

string

Inherited from

GMIError.getUserFriendlyMessage


toJSON()

toJSON(): Record<string, any>

Defined in: packages/agentos/src/utils/errors.ts:193

Returns

Record<string, any>

Inherited from

GMIError.toJSON


toPlainObject()

toPlainObject(): Record<string, any>

Defined in: packages/agentos/src/utils/errors.ts:180

Returns

Record<string, any>

Inherited from

GMIError.toPlainObject


captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: packages/agentos/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

function a() {
b();
}

function b() {
c();
}

function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;

// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}

a();

Parameters

targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

GMIError.captureStackTrace


isGMIError()

static isGMIError(error): error is GMIError

Defined in: packages/agentos/src/utils/errors.ts:197

Parameters

error

unknown

Returns

error is GMIError

Inherited from

GMIError.isGMIError


prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: packages/agentos/node_modules/@types/node/globals.d.ts:56

Parameters

err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

GMIError.prepareStackTrace


wrap()

static wrap(error, code, message, componentOrigin?): AgentOSServiceError

Defined in: packages/agentos/src/api/AgentOS.ts:278

Wraps an existing error object (which could be of any type) within a new AgentOSServiceError instance. This is useful for standardizing errors caught from lower layers or external libraries.

Parameters

error

any

The original error object to wrap.

code

string

The GMIErrorCode to assign to the new AgentOSServiceError.

message

string

A new, overarching message for the AgentOSServiceError. The original error's message will typically be included in the details.

componentOrigin?

string

Optional. The component where this wrapping is occurring or where the original error was caught and is being standardized.

Returns

AgentOSServiceError

A new instance of AgentOSServiceError encapsulating the original error.

Static

Example

try {
// some operation that might throw
} catch (e: unknown) {
throw AgentOSServiceError.wrap(e, GMIErrorCode.INTERNAL_SERVER_ERROR, "Failed to process user request", "RequestHandler");
}

Overrides

GMIError.wrap