Open clupasq opened 7 years ago
Add this code:
import Control.Exception (SomeException, catch, evaluate)
ignore :: SomeException -> Maybe a
ignore _ = Nothing
-- in `get "/snippet" $ do ...`
c <- param "code"
d <- liftIO $ catch (evaluate $ pointfree' c) (return . ignore)
case d of
Nothing -> json $ Error "..."
Just pf -> json $ ...
The problem is that, in the pointfree
package, unsupported constructs invoke the internal todo
function, which raises an error.
As a workaround, catch the error using the catch
function from Control.Exception
. As a note, it's necessary to force the evaluation of pointfree' c
using evaluate
.
The following code:
Produces an HTTP 500 error.