-reportError :: Bool -> String -> IO a
-reportError bombOut str = do
- (hFlush stdout) `catchException` (\ _ -> return ())
- withCStringLen str $ \(cstr,len) -> do
- writeErrString errorHdrHook cstr len
- if bombOut
- then exit 1
- else return undefined
-
-#ifndef ILX
-foreign import ccall "&ErrorHdrHook" errorHdrHook :: Ptr ()
-#else
-foreign import ccall "ErrorHdrHook" errorHdrHook :: Ptr ()
-#endif
-
-foreign import ccall unsafe "writeErrString__"
- writeErrString :: Ptr () -> CString -> Int -> IO ()
+reportError :: Bool -> Exception -> IO a
+reportError bombOut ex = do
+ handler <- getUncatchedExceptionHandler
+ handler ex
+ if bombOut
+ then exit 1
+ else return undefined