mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Handle ExitCodeException in wrapErr (#2415)
This is thrown by typed-process when the child process exits with a non-zero exitcode. fixes #2414
This commit is contained in:
parent
e0ced61770
commit
656d8f4a19
@ -63,6 +63,7 @@ da_haskell_library(
|
||||
"text",
|
||||
"time",
|
||||
"tls",
|
||||
"typed-process",
|
||||
"unix-compat",
|
||||
"utf8-string",
|
||||
"yaml",
|
||||
|
@ -14,6 +14,7 @@ import Control.Exception.Safe
|
||||
import Control.Applicative
|
||||
import Control.Monad.Extra
|
||||
import Data.Either.Extra
|
||||
import System.Process.Typed (ExitCodeException(..))
|
||||
|
||||
-- | Throw an assistant error.
|
||||
throwErr :: Text -> IO a
|
||||
@ -24,6 +25,7 @@ throwErr msg = throwIO (assistantError msg)
|
||||
wrapErr :: Text -> IO a -> IO a
|
||||
wrapErr ctx m = m `catches`
|
||||
[ Handler $ throwIO @IO @ExitCode
|
||||
, Handler $ \(ExitCodeException{eceExitCode}) -> exitWith eceExitCode
|
||||
, Handler $ throwIO . addErrorContext
|
||||
, Handler $ throwIO . wrapException
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user