@@ -21,6 +21,7 @@ import qualified Data.Text as T
2121import qualified Data.Text.IO as T
2222import qualified Data.Text.Encoding as T
2323import qualified System.Process as P
24+ import Control.Exception (displayExceptionWithInfo )
2425import Control.Monad.Except
2526import Control.Monad.Trans
2627import Data.Function
@@ -40,7 +41,6 @@ import System.FilePath
4041import Data.Functor.Contravariant
4142
4243import Development.Debug.Adapter
43- import Development.Debug.Adapter.Exit.Helpers
4444import Colog.Core as Logger
4545import qualified Development.Debug.Adapter.Output as Output
4646
@@ -95,15 +95,11 @@ data DAPLog
9595-- * Launch Debugger
9696--------------------------------------------------------------------------------
9797
98-
99- -- | Exception type for when hie-bios initialization fails
100- newtype InitFailed = InitFailed String deriving Show
101-
10298-- | Initialize debugger
10399--
104100-- Returns @()@ if successful, throws @InitFailed@ otherwise
105101initDebugger :: LogAction IO DAPLog -> Bool -> Bool
106- -> LaunchArgs -> ExceptT InitFailed DebugAdaptor ()
102+ -> LaunchArgs -> DebugAdaptor ()
107103initDebugger l supportsRunInTerminal preferInternalInterpreter
108104 LaunchArgs { __sessionId
109105 , projectRoot = givenRoot
@@ -116,7 +112,7 @@ initDebugger l supportsRunInTerminal preferInternalInterpreter
116112 syncResponses <- liftIO newEmptyMVar
117113
118114 entryFile <- case entryFileMaybe of
119- Nothing -> throwError $ InitFailed " Missing \" entryFile\" key in debugger configuration"
115+ Nothing -> throwError ( " Missing \" entryFile\" key in debugger configuration" , Nothing )
120116 Just ef -> pure ef
121117
122118 projectRoot <- maybe (liftIO getCurrentDirectory) pure givenRoot
@@ -142,8 +138,8 @@ initDebugger l supportsRunInTerminal preferInternalInterpreter
142138 | otherwise -> mempty
143139
144140 liftIO (runExceptT (hieBiosSetup hieBiosLogger projectRoot entryFile)) >>= \ case
145- Left e -> throwError $ InitFailed e
146- Right (Left e) -> lift $ terminateWithError e
141+ Left e -> throwError ( ErrorMessage ( T. pack e), Nothing )
142+ Right (Left e) -> throwError ( ErrorMessage ( T. pack e), Nothing )
147143 Right (Right flags) -> do
148144
149145 let
@@ -177,7 +173,7 @@ initDebugger l supportsRunInTerminal preferInternalInterpreter
177173 dbgLog <- liftIO $
178174 createDebuggerLogger l dapLogger writeDAPOutput runInTerminalProc
179175
180- (runInTerminalThreads, afterRegisterActions) <- lift $
176+ (runInTerminalThreads, afterRegisterActions) <-
181177 mkRunInTerminalThreads l runInTerminalProc preferInternalInterpreter
182178
183179 let
@@ -194,15 +190,15 @@ initDebugger l supportsRunInTerminal preferInternalInterpreter
194190 daState = DAS {entryFile= absEntryFile,.. }
195191
196192 sessionId <- liftIO $ maybe ((" debug-session:" <> ) . T. show <$> UUID. nextRandom) (pure . T. pack) __sessionId
197- lift $ registerNewDebugSession sessionId daState $
193+ registerNewDebugSession sessionId daState $
198194 [ debuggerThread dbgLog flags extraGhcArgs absEntryFile defaultRunConf syncRequests syncResponses
199195 , \ withAdaptor -> forwardHandleToLogger readDAPOutput $
200196 LogAction (\ msg -> withAdaptor (Output. neutral msg))
201197 ]
202198 ++
203199 runInTerminalThreads
204200
205- lift afterRegisterActions
201+ afterRegisterActions
206202
207203-- | Additional threads to register for this session depending on the process
208204-- we're running through `runInTerminal` (see 'RunInTerminalProc').
@@ -299,7 +295,7 @@ debuggerThread l HieBiosFlags{..} extraGhcArgs mainFp runConf requests replies w
299295 req <- takeMVar requests & liftIO
300296 resp <- (Debugger. execute req <&> Right )
301297 `catch` \ (e :: SomeException ) -> do
302- pure (Left (displayExceptionWithContext e))
298+ pure (Left (displayExceptionWithInfo e))
303299 case resp of
304300 Right x -> do
305301 liftIO (putMVar replies x)
0 commit comments