@@ -30,38 +30,38 @@ handleExceptions
3030handleExceptions 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
6061shouldDisplayException :: SomeException -> Bool
6162shouldDisplayException 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