Ensures that the given originalError is an instance of the given errorClass.
originalError
errorClass
import {ensureErrorClass, extractErrorMessage} from '@augment-vir/common';class MyCustomError extends Error { public override readonly name = 'MyCustomError';}try { // do some stuff} catch (error) { throw ensureErrorClass(error, MyCustomError, extractErrorMessage(error));} Copy
import {ensureErrorClass, extractErrorMessage} from '@augment-vir/common';class MyCustomError extends Error { public override readonly name = 'MyCustomError';}try { // do some stuff} catch (error) { throw ensureErrorClass(error, MyCustomError, extractErrorMessage(error));}
@augment-vir/common
Ensures that the given
originalError
is an instance of the givenerrorClass
.originalError
is directly returned.errorClass
is constructed with the given parameters.