The return value is the error message of a string type created from the expressions given in the values.
Example usage
// Example usage.
import { CommonError } from '@angular-package/error';
const problem = 'The given `age` parameter must be';
const fix = 'Provided string type is not accepted, change to ';
const id = 'AE: 427';
const template = `Issue({id}): {problem} of {type} between range {min} and {max}. {fix}{type}`;
const additional = { max: 27, min: 9, type: 'number' };
class TestError<Id extends string> extends CommonError<Id> {
public static isError<Id extends string>(
value: any,
id?: Id
): value is CommonError<Id> {
return super.isError(value, id);
}
public static defineMessage(
templateStringsArray: TemplateStringsArray,
...values: any[]
): string {
return super.defineMessage(templateStringsArray, ...values);
}
}
// Returns
// Issue(AE: 427): The given `age` parameter must be of number between range 9 and 27. Provided string type is not accepted, change to number
TestError.defineMessage`${problem}${fix}${id}${template}${additional}`;