- toException (ArithException exc) = SomeException exc
- toException (ArrayException exc) = SomeException exc
- toException (AssertionFailed err) = SomeException (New.AssertionFailed err)
- toException (AsyncException exc) = SomeException exc
- toException BlockedOnDeadMVar = SomeException New.BlockedOnDeadMVar
- toException BlockedIndefinitely = SomeException New.BlockedIndefinitely
- toException NestedAtomically = SomeException New.NestedAtomically
- toException Deadlock = SomeException New.Deadlock
- toException (DynException exc) = SomeException exc
- toException (ErrorCall err) = SomeException (New.ErrorCall err)
- toException (ExitException exc) = SomeException exc
- toException (IOException exc) = SomeException exc
- toException (NoMethodError err) = SomeException (New.NoMethodError err)
- toException NonTermination = SomeException New.NonTermination
- toException (PatternMatchFail err) = SomeException (New.PatternMatchFail err)
- toException (RecConError err) = SomeException (New.RecConError err)
- toException (RecSelError err) = SomeException (New.RecSelError err)
- toException (RecUpdError err) = SomeException (New.RecUpdError err)
+ toException (ArithException exc) = toException exc
+ toException (ArrayException exc) = toException exc
+ toException (AssertionFailed err) = toException (New.AssertionFailed err)
+ toException (AsyncException exc) = toException exc
+ toException BlockedOnDeadMVar = toException New.BlockedIndefinitelyOnMVar
+ toException BlockedIndefinitely = toException New.BlockedIndefinitelyOnSTM
+ toException NestedAtomically = toException New.NestedAtomically
+ toException Deadlock = toException New.Deadlock
+ -- If a dynamic exception is a SomeException then resurrect it, so
+ -- that bracket, catch+throw etc rethrow the same exception even
+ -- when the exception is in the new style.
+ -- If it's not a SomeException, then just throw the Dynamic.
+ toException (DynException exc) = case fromDynamic exc of
+ Just exc' -> exc'
+ Nothing -> toException exc
+ toException (ErrorCall err) = toException (New.ErrorCall err)
+ toException (ExitException exc) = toException exc
+ toException (IOException exc) = toException exc
+ toException (NoMethodError err) = toException (New.NoMethodError err)
+ toException NonTermination = toException New.NonTermination
+ toException (PatternMatchFail err) = toException (New.PatternMatchFail err)
+ toException (RecConError err) = toException (New.RecConError err)
+ toException (RecSelError err) = toException (New.RecSelError err)
+ toException (RecUpdError err) = toException (New.RecUpdError err)