static template

A template of the error message of string type with the replaceable tags

CommonError.template

A template of the error message of string type with the replaceable {problem}, {fix} and optional {id}, {link}, {max}, {min}, {type} tags.

By default, it's set to:

Problem{id}: {problem} => Fix: {fix}.

common-error.class.ts
public static template = `Problem{id}: {problem} => Fix: {fix}`;

Tags

Replaceable tags on the template.

{fix}

Replaceable by the given required fix parameter.

{id}

Replaceable by the given id parameter.

Replaceable by the property link of the given additional parameter.

{max}

Replaceable by the property max of the given additional parameter.

{min}

Replaceable by the property min of the given additional parameter.

{problem}

Replaceable by the given required problem parameter.

{type}

Replaceable by the property type of the given additional parameter.

Example usage

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

// Change the template.
CommonError.template = `Problem({id}): {problem} => Fix: {fix}`;

// Extend the `CommonError` class.
class TestError<Id extends string> extends CommonError<Id> {}

// Returns
// Error: Problem(AE:427): The `age` parameter is wrong. => Fix: Provided `age`
// must be different type.
new TestError(
  'The `age` parameter is wrong.', // Problem
  'Provided `age` must be different type. ', // Fix
  'AE:427' // Identification
);

Last updated