An optional object consists of optional link, min, max, and type properties to define the error message.
link - The link to read more about the thrown error replaceable on the given template as {link} tag.
max - The maximum number replaceable on the given template as {max} tag.
min - The minimum number is replaceable on the given template as {min} tag.
type - The type indicates the expected type that isn't throwing an error or the not expected type that is throwing an error replaceable on the given template as the {type} tag.
Example usage
Basic usage
Example with the given required problem and fix.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: Problem: problem => Fix: fix
throw new TestError(
'problem',
'fix'
);
id
Example with the given id.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: Problem(AE:427): problem => Fix: fix
throw new TestError(
'problem',
'fix',
'(AE:427)' // <--- Parameter `id`.
);
id, template
Example with the given id and template.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: problem(AE:427). fix
throw new TestError(
'problem',
'fix',
'AE:427', // <--- Parameter `id`
'{problem}({id}). {fix}' // <--- Parameter `template`
);
id, template, additional{ min }
Example with the given id, template and property min of additional.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: (AE:427)Age must be above 9. Provide age more than 9
throw new TestError(
'Age must be above ', // Problem
'Provide age more than ', // Fix
'AE:427', // Identification
'({id}){problem}{min}. {fix}{min}', // Template
{ min: 9 } // Additional
);
id, template, additional{ min, max }
Example with the given id, template and property min and max of additional.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: (AE:427)The `age` parameter is 45. Provided `age` must be between 9 and 12
throw new TestError(
'The `age` parameter is 45.', // Problem
'Provided `age` must be', // Fix
'AE:427', // Identification
'({id}){problem} {fix} between {min} and {max}', // Template
{ min: 9, max: 12 } // Additional
);
id, template, additional{ min, max, type }
Example with the given id, template, property min, max and type of additional.
// Example usage.
import { CommonError } from '@angular-package/error';
// Create `TestError` to extend.
class TestError<Id extends string> extends CommonError<Id> {}
// Uncaught Error: (AE:427)The `age` parameter is not a number. Provided `age` must be a number between 9 and 12.
throw new TestError(
'The `age` parameter is not a', // Problem
'Provided `age` must be a ', // Fix
'AE:427', // Identification
'({id}){problem} {type}. {fix} {type} between {min} and {max}.', // Template
{ min: 9, max: 12, type: 'number' } // Additional
);