static template

A template of the error message

TypeError.template

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

By default, it's set to Problem{id}: {problem} => Fix: {fix} must be of the {type}.

type-error.class.ts
public static template = `Problem{id}: {problem} => Fix: {fix} must be of the {type}`;

Example usage

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

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

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

Last updated