src/app/core/logging/reported-errors.ts

Description

What Logging.error(message, err) / Logging.warn(message, err) report: the logged message as the error, with the logged error as its cause.

Named "Error", so that titles read "Error: "; remote monitoring recognizes it by class instead.

Extends

Error

Relationships

Used by

No results matching.

Depends on

  • Error

Constructor

constructor(message: string, cause?: unknown)
Parameters :
Name Type Optional
message string No
cause unknown Yes
export class NamedError extends Error {
  /** Context for the report, kept out of the message so that it does not split the issue. */
  readonly details?: Record<string, unknown>;

  constructor(
    name: string,
    message: string,
    options?: {
      cause?: unknown;
      details?: Record<string, unknown>;
    },
  ) {
    super(
      message,
      options?.cause === undefined ? undefined : { cause: options.cause },
    );
    this.name = name;
    this.details = options?.details;
  }
}

/**
 * What `Logging.error(message, err)` / `Logging.warn(message, err)` report:
 * the logged message as the error, with the logged error as its `cause`.
 *
 * Named "Error", so that titles read "Error: <message>"; remote monitoring
 * recognizes it by class instead.
 */
export class LoggedError extends Error {
  constructor(message: string, cause?: unknown) {
    super(message, { cause });
    this.name = "Error";
  }
}

results matching ""

    No results matching ""