static define()

Defines the `Error` instance.

Error.define()

Defines the Error instance with the message built of the given required problem, fix and optional id on the given or stored template.

error.class.ts
public static define<Id extends string>(
  problem: string,
  fix: string,
  id?: Id,
  template = Error.template
): Error<Id> {
  return new this(problem, fix, id, template);
}

Generic type variables

Idextendsstring

A generic type variable constrained by the string, by default of the value captured from the provided optional id indicates the identification type of a new Error instance.

Parameters

problem:string

Description of the problem of a string type.

fix:string

A solution to the given problem of a string type.

id?:Id

Optional unique identification to the given problem of generic type variable Id.

template =Error.template

A template of error message with the replaceable {problem}, {fix} and optional {id} tags. By default, the value is equal to the static property template.

Return type

Error<Id>

The return type is the Error object that takes generic type variable Id.

Returns

The return value is a new instance of the Error with the message built from the given required problem, fix and optional id on the template.

Example usage

// Example usage.
import { Error } from '@angular-package/error';

// Returns "Error: ProblemTE:201: Wrong type => Fix: Change the type".
Error.define('Wrong type', 'Change the type', 'TE:201');

Last updated