[Haskell-cafe] Absolutely confused with error/exception handling
Brandon Allbery
allbery.b at gmail.com
Fri Dec 16 02:30:34 UTC 2016
whoops, pressed wrong key...
No guarantees are made as to when the exception thrown by `throw` occurs;
this allows it to be thrown from pure code. `throwIO` is sequenced as any
other I/O operation, so you have some guarantee as to I/O operations before
the `throwIO` being performed.
On Thu, Dec 15, 2016 at 9:28 PM, Brandon Allbery <allbery.b at gmail.com>
wrote:
>
> On Thu, Dec 15, 2016 at 8:42 PM, Saurabh Nanda <saurabhnanda at gmail.com>
> wrote:
>
>> * What exactly is done by the "error" function? How does one "trap" those
>> errors and react to it? Can "catch" trap those errors? What is "e" in the
>> case of errors raised by "error"?
>>
>
> `error` specifically raises a UserError exception, with a user-specified
> payload (message). `catch` can catch them as such.
>
>
>> * How is "error" different from "throw" and "throwIO" (in the
>> Control.Exception package, I believe)
>>
>
> `throw` (for pure code / asynchronous) and `throwIO` (for code in IO) can
> throw any exception. No guarantees are made as to when the exception thrown
> by `throw`
>
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> allbery.b at gmail.com
> ballbery at sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20161215/1463bcb1/attachment.html>
More information about the Haskell-Cafe
mailing list