asilvestre / haskell-neo4j-rest-client

Haskell neo4j REST client
MIT License
25 stars 7 forks source link

runBatch doesn't throw exceptions, only throws if result is evaluated #31

Open mgsloan opened 7 years ago

mgsloan commented 7 years ago

If you do runNeo4j (void $ runBatch f) conn, even if the batch fails you never get exceptions. This is extremely surprising and counterintuitive for the user. Generally, you should avoid error and throw in most code, throwing exceptions from pure values is terrible for API users, we do not expect it. In particular, it is unexpected that something that essentially lives in IO would use throw rather than throwIO.

This is a very common pattern, since you rarely care about the Graph that results from a batch operation.

I think the quick fix would be to use $! after the return in the definition of runBatch, but it would be better to use throwIO.