mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-12 04:32:50 -06:00
better error handling which always reports the right file name
This commit is contained in:
@@ -193,7 +193,7 @@ newtype PGFError = PGFError String
|
||||
|
||||
instance Exception PGFError
|
||||
|
||||
withPgfExn fpath f =
|
||||
withPgfExn f =
|
||||
allocaBytes (#size PgfExn) $ \c_exn -> do
|
||||
res <- f c_exn
|
||||
ex_type <- (#peek PgfExn, type) c_exn :: IO (#type PgfExnType)
|
||||
@@ -201,7 +201,11 @@ withPgfExn fpath f =
|
||||
(#const PGF_EXN_NONE) -> return res
|
||||
(#const PGF_EXN_SYSTEM_ERROR) -> do
|
||||
errno <- (#peek PgfExn, code) c_exn
|
||||
ioError (errnoToIOError "readPGF" (Errno errno) Nothing (Just fpath))
|
||||
c_msg <- (#peek PgfExn, msg) c_exn
|
||||
mb_fpath <- if c_msg == nullPtr
|
||||
then return Nothing
|
||||
else fmap Just (peekCString c_msg)
|
||||
ioError (errnoToIOError "readPGF" (Errno errno) Nothing mb_fpath)
|
||||
(#const PGF_EXN_PGF_ERROR) -> do
|
||||
c_msg <- (#peek PgfExn, msg) c_exn
|
||||
msg <- peekCString c_msg
|
||||
|
||||
@@ -42,7 +42,7 @@ modifyPGF :: PGF -> Transaction a -> IO PGF
|
||||
modifyPGF p (Transaction f) =
|
||||
withForeignPtr (a_db p) $ \c_db ->
|
||||
withForeignPtr (revision p) $ \c_revision ->
|
||||
withPgfExn "" $ \c_exn -> do
|
||||
withPgfExn $ \c_exn -> do
|
||||
c_revision <- pgf_clone_revision c_db c_revision c_exn
|
||||
ex_type <- (#peek PgfExn, type) c_exn
|
||||
if (ex_type :: (#type PgfExnType)) == (#const PGF_EXN_NONE)
|
||||
|
||||
Reference in New Issue
Block a user