Class AgentOSServiceError

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.

Hierarchy

  • GMIError
    • AgentOSServiceError

Constructors

  • 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.

    • Optional details: any

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

    • Optional 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

Methods

  • 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.

    • Optional 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");
    }
  • Returns number

  • Returns string

  • Returns Record<string, any>

  • Returns Record<string, any>

  • Parameters

    • error: unknown

    Returns error is GMIError

Properties

name: string = 'AgentOSServiceError'

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

code: string
details?: any
component?: string
timestamp: string
httpStatusCode?: number
cause?: unknown