[Haskell-cafe] Control.Exception Funny
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sat Nov 29 16:56:44 EST 2008
Claus Reinke wrote:
> btw, if your handler cannot return the same type as your action, is this
> the right place to catch the exceptions?
>
That was an example, the real code looks something like this:
> do d <- getCurrentDirectory
> t <- getCurrentTime
> let u = "asn1c." ++ show (utctDay t) ++ "." ++ show (utctDayTime t)
> createDirectory u
> setCurrentDirectory u
> CE.catch (do writeASN1AndC (genFile <.> "asn1") (genFile <.> "c") ty val
> runCommands [(asn1c ++ " " ++ asn1cOptions ++ " " ++ skeletons ++ " " ++ (genFile <.> "asn1"), "Failure in asn1c")]
> d <- getCurrentDirectory
> fs <- getDirectoryContents d
> let cFiles =
> case os of
> "mingw32" ->
> (genFile <.> "c"):(name <.> "c"):(cFiles' ["converter-sample.c"] ".c.lnk" fs)
> _ ->
> (genFile <.> "c"):(name <.> "c"):(cFiles' [genFile <.> "c", name <.> "c", "converter-sample" <.> "c"] ".c" fs)
> putStrLn (show cFiles)
> putStrLn (show (map compile cFiles))
> runCommands (map compile cFiles)
> putStrLn (linker ++ " " ++ linkerOut genFile ++ " " ++ ("*" <.> objectSuffix))
> runCommands [
> (linker ++ " " ++ linkerOut genFile ++ " " ++ ("*" <.> objectSuffix), "Failure linking"),
> ((executable genFile) ++ " " ++ (genFile <.> "per"), "Failure executing")
> ]
> readGen (genFile <.> "per") ty)
> (\e -> hPutStrLn stderr ("Problem with generating / compiling\n" ++ show e))
> setCurrentDirectory d
Your suggestion:
> you'll see 'IOException' listed, so 'show (e::IOException)' might do
> what you want.
works perfectly.
Thanks very much, Dominic.
More information about the Haskell-Cafe
mailing list