As of typescript 4.4.x thrown Errors are of unknown type so this function is used
to assert that the error is of the expected type and attempts to convert the error to the expected type.
Parameters
err: unknown
The error to assert.
Returns Error
The original error if it is of the expected type otherwise the converted error.
As of typescript 4.4.x thrown Errors are of unknown type so this function is used to assert that the error is of the expected type and attempts to convert the error to the expected type.