aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent/snmp_generic.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-05-10 07:25:50 +0200
committerBjörn Gustavsson <[email protected]>2017-05-11 12:17:18 +0200
commit5d7e12f4d037f74602029850bbd29e38c3732b48 (patch)
tree98e6598bc03dd97fa1dd34b300dbd2e8736549b8 /lib/snmp/src/agent/snmp_generic.erl
parent3681218fc3193693f4a22c818925a2765b5121fb (diff)
downloadotp-5d7e12f4d037f74602029850bbd29e38c3732b48.tar.gz
otp-5d7e12f4d037f74602029850bbd29e38c3732b48.tar.bz2
otp-5d7e12f4d037f74602029850bbd29e38c3732b48.zip
snmp_generic: Future-proof exception handling code
In the future, erlang:get_stacktrace/0 will probably only work inside a the 'catch' block of a 'try' expression. Future-proof the code by rewriting the old-style catch to a try...catch.
Diffstat (limited to 'lib/snmp/src/agent/snmp_generic.erl')
-rw-r--r--lib/snmp/src/agent/snmp_generic.erl28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/snmp/src/agent/snmp_generic.erl b/lib/snmp/src/agent/snmp_generic.erl
index fc23e16ef1..4738525341 100644
--- a/lib/snmp/src/agent/snmp_generic.erl
+++ b/lib/snmp/src/agent/snmp_generic.erl
@@ -413,20 +413,21 @@ table_check_status(NameDb, Col, ?'RowStatus_createAndGo', RowIndex, Cols) ->
false ->
% it's ok to use snmpa_local_db:table_construct_row since it's
% side effect free and we only use the result temporary.
- case catch snmpa_local_db:table_construct_row(
+ try snmpa_local_db:table_construct_row(
NameDb, RowIndex, ?'RowStatus_createAndGo', Cols) of
- {'EXIT', _Reason} ->
- ?vtrace(
- "failed construct row (createAndGo): "
- " n Reason: ~p"
- " n Stack: ~p",
- [_Reason, erlang:get_stacktrace()]),
- {noCreation, Col}; % Bad RowIndex
Row ->
case lists:member(noinit, tuple_to_list(Row)) of
false -> {noError, 0};
_Found -> {inconsistentValue, Col}
end
+ catch
+ _:_Reason ->
+ ?vtrace(
+ "failed construct row (createAndGo): "
+ " n Reason: ~p"
+ " n Stack: ~p",
+ [_Reason, erlang:get_stacktrace()]),
+ {noCreation, Col} % Bad RowIndex
end;
true -> {inconsistentValue, Col}
end;
@@ -435,17 +436,18 @@ table_check_status(NameDb, Col, ?'RowStatus_createAndGo', RowIndex, Cols) ->
table_check_status(NameDb, Col, ?'RowStatus_createAndWait', RowIndex, Cols) ->
case table_row_exists(NameDb, RowIndex) of
false ->
- case catch snmpa_local_db:table_construct_row(
+ try snmpa_local_db:table_construct_row(
NameDb, RowIndex, ?'RowStatus_createAndGo', Cols) of
- {'EXIT', _Reason} ->
+ _Row ->
+ {noError, 0}
+ catch
+ _:_Reason ->
?vtrace(
"failed construct row (createAndWait): "
" n Reason: ~p"
" n Stack: ~p",
[_Reason, erlang:get_stacktrace()]),
- {noCreation, Col}; % Bad RowIndex
- _Row ->
- {noError, 0}
+ {noCreation, Col} % Bad RowIndex
end;
true -> {inconsistentValue, Col}
end;