aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-12-05 12:53:25 +0100
committerMicael Karlberg <[email protected]>2011-12-21 16:04:04 +0100
commit558f3c606b2cbdf46ecb53de48387ebb93527c07 (patch)
tree98d7a3f28a7cb15d0a3362a771d46a7d82caf8e2 /lib/snmp/src/agent
parent44afbca7de2d14993df33d5329a9699a588ff6b0 (diff)
downloadotp-558f3c606b2cbdf46ecb53de48387ebb93527c07.tar.gz
otp-558f3c606b2cbdf46ecb53de48387ebb93527c07.tar.bz2
otp-558f3c606b2cbdf46ecb53de48387ebb93527c07.zip
[snmp] Add a more informative return value when the trap sending fails
OTP-9700
Diffstat (limited to 'lib/snmp/src/agent')
-rw-r--r--lib/snmp/src/agent/snmpa_trap.erl20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/snmp/src/agent/snmpa_trap.erl b/lib/snmp/src/agent/snmpa_trap.erl
index 450cb2e9f4..3b31c8d909 100644
--- a/lib/snmp/src/agent/snmpa_trap.erl
+++ b/lib/snmp/src/agent/snmpa_trap.erl
@@ -339,9 +339,25 @@ send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs, NetIf) ->
send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs,
LocalEngineID, NetIf).
+%% The agent normally does not care about the result,
+%% but since it can be usefull when debugging, add
+%% some info when we fail to send the trap(s).
send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs, LocalEngineID, NetIf) ->
- (catch do_send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs,
- LocalEngineID, NetIf)).
+ try
+ begin
+ do_send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs,
+ LocalEngineID, NetIf)
+ end
+ catch
+ T:E ->
+ Info = [{args, [TrapRec, NotifyName, ContextName,
+ Recv, Vbs, LocalEngineID, NetIf]},
+ {tag, T},
+ {err, E},
+ {stacktrace, erlang:get_stacktrace()}],
+ {error, {failed_sending_trap, Info}}
+ end.
+
do_send_trap(TrapRec, NotifyName, ContextName, Recv, Vbs,
LocalEngineID, NetIf) ->