Creates a new class of Error for issues to be returned to users. Using this error allows a web framework handler (e.g. express, next) to know it is safe to return the message in a request. Other kinds of errors will result in a generic 500 message to avoid the possibility of internal exceptions being leaked to attackers. In JSON requests, code will be an HTTP code and error will be a response body. In streaming requests, { code, message } will be passed as the error message.

Hierarchy (View Summary)

Constructors

  • Parameters

    • status:
          | "OK"
          | "CANCELLED"
          | "UNKNOWN"
          | "INVALID_ARGUMENT"
          | "DEADLINE_EXCEEDED"
          | "NOT_FOUND"
          | "ALREADY_EXISTS"
          | "PERMISSION_DENIED"
          | "UNAUTHENTICATED"
          | "RESOURCE_EXHAUSTED"
          | "FAILED_PRECONDITION"
          | "ABORTED"
          | "OUT_OF_RANGE"
          | "UNIMPLEMENTED"
          | "INTERNAL"
          | "UNAVAILABLE"
          | "DATA_LOSS"
    • message: string
    • Optionaldetails: any

    Returns UserFacingError

Properties

cause?: unknown
code: number
detail?: any
message: string
name: string
originalMessage: string
source?: string
stack?: string
status:
    | "OK"
    | "CANCELLED"
    | "UNKNOWN"
    | "INVALID_ARGUMENT"
    | "DEADLINE_EXCEEDED"
    | "NOT_FOUND"
    | "ALREADY_EXISTS"
    | "PERMISSION_DENIED"
    | "UNAUTHENTICATED"
    | "RESOURCE_EXHAUSTED"
    | "FAILED_PRECONDITION"
    | "ABORTED"
    | "OUT_OF_RANGE"
    | "UNIMPLEMENTED"
    | "INTERNAL"
    | "UNAVAILABLE"
    | "DATA_LOSS"
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Returns a JSON-serializable representation of this object.

    Returns HttpErrorWireFormat

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void