src/app/utils/backend-errors.ts

Description

A request that never reached our backend (no response at all, or a gateway status).

Extends

TypedError

Relationships

Depends on

Index

Properties

Constructor

constructor(message: string, options?: TypedErrorOptions)
Parameters :
Name Type Optional
message string No
options TypedErrorOptions Yes

Properties

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 status
Type : number
Inherited from TypedError

The HTTP status of the failed request, if any.

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 ""