
22 Nov
2008
22 Nov
'08
4 p.m.
On Sat, 22 Nov 2008, Thomas Schilling wrote:
Be careful, though. This only works if there's a single constructor for your exception type. If there are multiple, you should write it like this:
thing_to_try `catch` \(e :: MyErrorType) -> case e of MyError1 _ -> ..; MyError2 _ -> ...
If you write `catch` (MyError1 ...) and a MyError2 is thrown, you will get a pattern match error exception.
A "pattern match exception" or "pattern match error"? I mean, not handling a certain pattern is a programming error not an exceptional condition at runtime. Thus there is no need to throw a "pattern match exception" which is catched and handled somewhere else.