Constructor
The `CommonErrors` constructor
CommonErrors()
CommonErrors()
Creates an instance of the errors storage with unique identification numbers.
constructor(...id: Id[]) {
Array.isArray(id) && (this.#id = new Set(id));
}
Parameters
A rest parameter of generic type variable Id
indicates unique identification numbers under which the errors are stored in the object.
Example usage
// Example usage.
import { CommonErrors } from '@angular-package/error';
class CustomErrors<Id extends string> extends CommonErrors<Id> {
constructor(...id: Id[]) {
super(...id);
}
}
// Initialize `CustomErrors` without defined `id`.
// Returns CustomErrors {} of CustomErrors<string>
new CustomErrors();
// Initialize `CustomErrors` with defined `id`.
// Returns CustomErrors {} of CustomErrors<"ERR1" | "ERR2" | "ERR3">
new CustomErrors('ERR1', 'ERR2', 'ERR3');
Last updated
Was this helpful?