ensure<T, U, E>(error, create?, options?): T extends E ? T : U
Will return error if an instance of Error is passed;
otherwise, when lacking a create function,
it will instantiate an Exception and return it.
When a new Exception is created, Exception.data
will be populated with error.
Will return
error
if an instance ofError
is passed; otherwise, when lacking acreate
function, it will instantiate anException
and return it. When a newException
is created,Exception.data
will be populated witherror
.