Skip to content

Commit f0ee9eb

Browse files
committed
wasm: simplify error catching.
1 parent 50bcbb5 commit f0ee9eb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pandoc-cli/src/pandoc.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import qualified Data.Aeson as Aeson
4040
import qualified Text.Pandoc.UTF8 as UTF8
4141
import qualified Data.Text.IO as TIO
4242
import qualified Data.ByteString.Lazy as BL
43-
import Text.Pandoc.Error (renderError, PandocError)
4443
import Text.Pandoc.Logging (showLogMessage)
4544
#else
4645
import System.Exit
@@ -62,7 +61,7 @@ foreign export ccall "wasm_main" wasm_main :: Ptr CChar -> Int -> IO ()
6261

6362
wasm_main :: Ptr CChar -> Int -> IO ()
6463
wasm_main raw_args_ptr raw_args_len =
65-
catch act (\(err :: SomeException) -> writeFile "/stderr" (show err))
64+
E.catch act (\(err :: SomeException) -> writeFile "/stderr" (displayException err))
6665
where
6766
act = do
6867
args <- peekCStringLen (raw_args_ptr, raw_args_len)
@@ -76,8 +75,7 @@ wasm_main raw_args_ptr raw_args_len =
7675
, optOutputFile = Just $ fromMaybe "/stdout" (optOutputFile opts)
7776
, optLogFile = Just $ fromMaybe "/warnings" (optLogFile opts)
7877
}
79-
E.catch (convertWithOpts engine opts') $
80-
\(e :: PandocError) -> TIO.writeFile "/stderr" (renderError e)
78+
convertWithOpts engine opts'
8179
res <- Aeson.eitherDecode <$> BL.readFile "/warnings"
8280
case res of
8381
Left e -> writeFile "/stderr" e

0 commit comments

Comments
 (0)