hasql icon indicating copy to clipboard operation
hasql copied to clipboard

Add an Exception instance to QueryError

Open jfischoff opened this issue 5 years ago • 2 comments

In varying contexts I would like to be able to use throwIO with QueryError. Instead of wrapping it a newtype I would prefer if there was a Exception instance already defined. I think the default instance would be fine.

So the changes would be:

data QueryError =
  QueryError ByteString [Text] CommandError
  deriving (Show, Eq, Typeable)

instance Exception QueryError

I don't think this will break code nor will it incur an additional dependency.

jfischoff avatar Feb 09 '20 23:02 jfischoff

Although I feel opposed to this since I consider the presence of exceptions in Haskell altogether a mistake, this is not the first time I get this request. So okay, let's do this! Can you make a PR?

nikita-volkov avatar Feb 10 '20 07:02 nikita-volkov

Yep. I'll make a PR.

I get the dislike of exceptions. I find them useful in tests.

jfischoff avatar Feb 10 '20 17:02 jfischoff

Can this be closed?

mitchellwrosen avatar Jan 10 '23 17:01 mitchellwrosen

Yep. Thanks. QueryError has an Exception instance now.

nikita-volkov avatar Jan 10 '23 19:01 nikita-volkov