The signature for match in Try doesn't pass the error into the handler:
match<B>(matcher: { Success: (a: A) => B, Failure: () => B }): B;
I see that if I have a Failure, I can access .exception to get at the error object. But the match function doesn't narrow down the type of Try to Failure for the handler block. I tried just doing an if (foo.isFailure) { foo.exception}..., but there doesn't appear to be a type guard function defined for Failure either.
What's the idiomatic way to get at the error associated with a failed Try?
And big thanks for the library, I've found myself using it more and more often as time goes on.
The signature for
match
inTry
doesn't pass the error into the handler:I see that if I have a
Failure
, I can access.exception
to get at the error object. But thematch
function doesn't narrow down the type ofTry
toFailure
for the handler block. I tried just doing anif (foo.isFailure) { foo.exception}...
, but there doesn't appear to be a type guard function defined forFailure
either.What's the idiomatic way to get at the error associated with a failed Try?
And big thanks for the library, I've found myself using it more and more often as time goes on.