getErrors()
The method returns the object of set errors
Errors.prototype.getErrors()
Errors.prototype.getErrors()Returns an object of set errors, where the key is a unique identification.
public getErrors(): { [Key in Id]: Error<Key> | undefined } {
return Object.fromEntries(this.errors.entries()) as any;
}Return type
A return type is an object of the Error objects or undefined in the keys of generic type variable Id.
Returns
The return value is an object of set errors.
Example usage
// Example usage.
import { Errors } from '@angular-package/error';
// Define general errors.
const generalErrors = new Errors('EG: 4332', 'EG: 4331', 'EG: 4330');
// Set the `Error` objects under the given identification numbers.
generalErrors
.set(
'Bad parameter type, detected number',
'Provide proper type, the `string`',
'EG: 4330'
)
.set('Detected numbers', 'Provide only letters', 'EG: 4331');
// Returns:
/*
Returns
{
EG: 4330: ...,
EG: 4331: ...
}
of type
{
"EG: 4332": Error<"EG: 4332">;
"EG: 4331": Error<"EG: 4331">;
"EG: 4330": Error<"EG: 4330">;
}
*/
generalErrors.getErrors();Last updated
Was this helpful?