src/app/utils/backend-errors.ts

Description

Our backend answered with a 5xx status other than a gateway status.

Extends

TypedError

Relationships

Used by

No results matching.

Depends on

Index

Properties

Constructor

constructor(message: string, options: TypedErrorOptions & literal type)
Parameters :
Name Type Optional
message string No
options TypedErrorOptions & literal type No

Properties

Readonly status
Type : number
Inherited from TypedError
Readonly classification
Type : ErrorClassification
Inherited from TypedError

The kind of failure: an own property, so that a copy of the error that lost its class (as PouchDB's createError() makes) still has it.

Readonly Optional details
Type : Record<string, unknown>
Inherited from NamedError

Context for the report, kept out of the message so that it does not split the issue.

import {
  TypedError,
  TypedErrorOptions,
} from "#src/app/core/logging/error-classification";

/**
 * The typed errors of a failed request to our backend (CouchDB, the API, Keycloak),
 * shared by the boundaries that convert such failures (the database layer, the
 * HTTP interceptor, the Keycloak service), see `backend-response.ts`.
 */

/** A request that never reached our backend (no response at all, or a gateway status). */
export class ConnectivityError extends TypedError {
  constructor(message: string, options?: TypedErrorOptions) {
    super("ConnectivityError", "connectivity", message, options);
  }
}

/** Our backend answered with a 5xx status other than a gateway status. */
export class ServerError extends TypedError {
  declare readonly status: number;

  constructor(
    message: string,
    options: TypedErrorOptions & { status: number },
  ) {
    super("ServerError", "server-error", message, options);
  }
}

results matching ""

    No results matching ""