static define()
Defines the `Error` instance.
Error.define()
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
.
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
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
problem:
string
Description of the problem of a string
type.
fix:
string
fix:
string
A solution to the given problem
of a string
type.
id?:
Id
id?:
Id
Optional unique identification to the given problem
of generic type variable Id
.
template =
Error
.template
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
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
Was this helpful?