Skip to content

Commit 89bfde6

Browse files
committed
Hide Warp exceptions better in logs
1 parent 5848c2a commit 89bfde6

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

flora.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ common common-rts-options
6969
-rtsopts
7070
-threaded
7171
"-with-rtsopts=-N -Iw1 --disable-delayed-os-memory-return -T"
72+
7273
-- Use TCMalloc instead of glibc's malloc.
7374
if !(os(osx) && arch(aarch64))
7475
pkgconfig-depends: libtcmalloc

src/web/FloraWeb/Common/Tracing.hs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,38 @@ handleExceptions
3030
handleExceptions logger environment mltp mRequest e@(E.SomeException exception) = do
3131
Log.runLogT "flora-production" logger LogAttention $ do
3232
let context = E.displayExceptionContext $ E.someExceptionContext e
33-
Log.logAttention "Unhandled exception" $
34-
Aeson.object
35-
[ "exception" .= display (show exception)
36-
, "backtraces" .= context
37-
]
38-
case mltp.sentryDSN of
39-
Nothing -> throw exception
40-
Just sentryDSN ->
41-
if shouldDisplayException e && isJust mRequest
42-
then do
43-
sentryService <-
44-
liftIO $
45-
initRaven
46-
sentryDSN
47-
(\defaultRecord -> defaultRecord{srEnvironment = Just $ show environment})
48-
sendRecord
49-
silentFallback
50-
liftIO $
51-
register
52-
sentryService
53-
"flora-server"
54-
Error
55-
(formatMessage mRequest e)
56-
(recordUpdate mRequest e)
57-
liftIO $ defaultOnException mRequest e
58-
else liftIO $ defaultOnException mRequest e
33+
when (shouldDisplayException e) $
34+
Log.logAttention "Unhandled exception" $
35+
Aeson.object
36+
[ "exception" .= display (show exception)
37+
, "backtraces" .= context
38+
]
39+
case mltp.sentryDSN of
40+
Nothing -> throw exception
41+
Just sentryDSN ->
42+
if isJust mRequest
43+
then do
44+
sentryService <-
45+
liftIO $
46+
initRaven
47+
sentryDSN
48+
(\defaultRecord -> defaultRecord{srEnvironment = Just $ show environment})
49+
sendRecord
50+
silentFallback
51+
liftIO $
52+
register
53+
sentryService
54+
"flora-server"
55+
Error
56+
(formatMessage mRequest e)
57+
(recordUpdate mRequest e)
58+
liftIO $ defaultOnException mRequest e
59+
else liftIO $ defaultOnException mRequest e
5960

6061
shouldDisplayException :: SomeException -> Bool
6162
shouldDisplayException exception
6263
| Just ThreadKilled <- fromException exception = False
6364
| Just TimeoutThread <- fromException exception = False
64-
| Just ConnectionClosedByPeer <- fromException exception = False
6565
| Just (_ :: InvalidRequest) <- fromException exception = False
6666
| Just (ioeGetErrorType -> et) <- fromException exception
6767
, et == ResourceVanished || et == InvalidArgument =

0 commit comments

Comments
 (0)