static isError()
Checks whether the value of any type is a this instance of any or the given identification
CommonError.isError()
CommonError.isError()Checks whether the value of any type is a this instance of any or the given identification.
protected static isError<Id extends string>(
  value: any,
  id?: Id
): value is CommonError<Id> {
  return typeof value === 'object' && value instanceof this
    ? typeof id === 'string'
      ? value.id === id
      : true
    : false;
}Generic type variables
A generic type variable constrained by the string indicates the 
Parameters
value:any
value:anyThe value of any type to check against the this instance.
Optional identification of generic type variable Id to check whether the given value contains.
Return type
The return type is a boolean indicating the value is the CommonError object that takes generic type variable Id.
Returns
The return value is a boolean type indicating whether the given value is a this instance of any or the given id.
Example usage
// Example usage.
import { CommonError } from '@angular-package/error';
class TestError<Id extends string> extends CommonError<Id> {
  public static isError<Id extends string>(
    value: any,
    id?: Id
  ): value is TestError<Id> {
    return super.isError(value, id);
  }
}
const testError = new TestError(
  'Problem accessor.',
  'Fix accessor.',
  '(AE:427)',
  '{problem} {fix} {id}'
);
// Returns "true".
TestError.isError(testError, '(AE:427)');Last updated
Was this helpful?
