@@ -15,13 +15,16 @@ import Control.Concurrent.Async (Async, async)
15
15
import Control.Concurrent.Extra (Var , modifyVar_ , newVar ,
16
16
readVar , threadDelay )
17
17
import Control.Exception (evaluate )
18
- import Control.Exception.Safe (SomeException , catch )
18
+ import Control.Exception.Safe (SomeException , catch ,
19
+ generalBracket )
19
20
import Control.Monad (forM_ , forever , unless , void ,
20
21
when , (>=>) )
22
+ import Control.Monad.Catch (ExitCase (.. ))
21
23
import Control.Monad.Extra (whenJust )
22
24
import Control.Monad.IO.Unlift
23
25
import Control.Seq (r0 , seqList , seqTuple2 , using )
24
26
import Data.ByteString (ByteString )
27
+ import Data.ByteString.Char8 (pack )
25
28
import Data.Dynamic (Dynamic )
26
29
import qualified Data.HashMap.Strict as HMap
27
30
import Data.IORef (modifyIORef' , newIORef ,
@@ -32,7 +35,7 @@ import Debug.Trace.Flags (userTracingEnabled)
32
35
import Development.IDE.Core.RuleTypes (GhcSession (GhcSession ),
33
36
GhcSessionDeps (GhcSessionDeps ),
34
37
GhcSessionIO (GhcSessionIO ))
35
- import Development.IDE.Graph (Action , actionBracket )
38
+ import Development.IDE.Graph (Action )
36
39
import Development.IDE.Graph.Rule
37
40
import Development.IDE.Types.Location (Uri (.. ))
38
41
import Development.IDE.Types.Logger (Logger , logDebug , logInfo )
@@ -83,21 +86,24 @@ otTracedAction
83
86
-> Action (RunResult a ) -- ^ The action
84
87
-> Action (RunResult a )
85
88
otTracedAction key file mode success act
86
- | userTracingEnabled =
87
- actionBracket
89
+ | userTracingEnabled = fst <$>
90
+ generalBracket
88
91
(do
89
92
sp <- beginSpan (fromString (show key))
90
93
setTag sp " File" (fromString $ fromNormalizedFilePath file)
91
94
setTag sp " Mode" (fromString $ show mode)
92
95
return sp
93
96
)
94
- endSpan
95
- (\ sp -> do
96
- res <- act
97
- unless (success $ runValue res) $ setTag sp " error" " 1"
98
- setTag sp " changed" $ case res of
99
- RunResult x _ _ -> fromString $ show x
100
- return res)
97
+ (\ sp ec -> do
98
+ case ec of
99
+ ExitCaseAbort -> setTag sp " aborted" " 1"
100
+ ExitCaseException e -> setTag sp " exception" (pack $ show e)
101
+ ExitCaseSuccess res -> do
102
+ unless (success $ runValue res) $ setTag sp " error" " 1"
103
+ setTag sp " changed" $ case res of
104
+ RunResult x _ _ -> fromString $ show x
105
+ endSpan sp)
106
+ (\ _ -> act)
101
107
| otherwise = act
102
108
103
109
#if MIN_VERSION_ghc(8,8,0)
0 commit comments