@@ -8,14 +8,16 @@ module Pos.Reporting.Production
8
8
9
9
import Universum
10
10
11
+ import Control.Exception.Safe (catchIO )
12
+
11
13
import Pos.Core (ProtocolMagic )
12
14
import Pos.Infra.Diffusion.Types (Diffusion )
13
15
import Pos.Infra.Reporting (Reporter (.. ))
14
16
import Pos.Infra.Reporting.Http (reportNode )
15
17
import Pos.Infra.Reporting.NodeInfo (extendWithNodeInfo )
16
18
import Pos.Infra.Reporting.Wlog (LoggerConfig , withWlogTempFile )
17
19
import Pos.Util.CompileInfo (CompileTimeInfo )
18
- import Pos.Util.Trace (Severity , Trace )
20
+ import Pos.Util.Trace (Severity ( Error ) , Trace , traceWith )
19
21
20
22
data ProductionReporterParams = ProductionReporterParams
21
23
{ prpServers :: ! [Text ]
@@ -32,9 +34,16 @@ productionReporter
32
34
productionReporter params diffusion = Reporter $ \ rt -> withWlogTempFile logConfig $ \ mfp -> do
33
35
rt' <- extendWithNodeInfo diffusion rt
34
36
reportNode logTrace protocolMagic compileTimeInfo servers mfp rt'
37
+ `catchIO`
38
+ reportExnHandler rt'
35
39
where
36
40
servers = prpServers params
37
41
logConfig = prpLoggerConfig params
38
42
protocolMagic = prpProtocolMagic params
39
43
compileTimeInfo = prpCompileTimeInfo params
40
44
logTrace = prpTrace params
45
+ --
46
+ reportExnHandler rt e =
47
+ let msgToLog = " reportNode encountered IOException `" <> show e
48
+ <> " ` while trying to report the message:" <> show rt
49
+ in liftIO (traceWith logTrace (Error , msgToLog))
0 commit comments