Closed rubenmoor closed 2 years ago
I found the cause of my error:
When using evalSnap
, the function throwError :: MonadSnap m => ServantErr -> m a
from servant-snap
doesn't work. Instead of getting the HTTP error that I specify, I get the IO exception above (throwIO $ ErrorCall "no value"
).
I don't know whether this problems originiates in evalSnap
and thus snap-core
or within throwError
and thus servant-snap
.
I also don't know whether this is tolerated behavior. Maybe evalSnap
isn't meant to be used with throwError
. Maybe I can safely switch to runSnap
.
I am currently working with snap-core-1.0.4.1 and snap-server-1.1.1.2 and can't easily swap out either of them.
Given that the documentation of servant-snap states
throwError :: MonadSnap m => ServantErr -> m a
Terminate request handling with a ServantErr via finishWith
... and evalSnap
has a very specific use, not a general one, I conclude this is by no means a bug. I guess I would prefer a variant of evalSnap
that evaluates to IO (Maybe a)
or something instead of throwing IO exceptions.
I got this error message and can't make out the cause:
The only hint I get from Snap is
I first checked the handler for /api/usr/app/get but it's a really lean handler that doesn't do much. I then checked the authentication middleware which is custom code of mine. It looks Snap throws an IO exception somewhere while verifying my Json web token ... but I do proper error handling, and by adding
catch
, I couldn't find the offending piece of code.Also, this my authentication middle ware is tested and worked fine about a year ago.
The only thing that I could find in the snap code on github and that resembles the error is this:
This is my code: