1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2002-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(snmpa_error). 21 22-behaviour(snmpa_error_report). 23 24 25%%%----------------------------------------------------------------- 26%%% Implements different error mechanisms. 27%%%----------------------------------------------------------------- 28-export([user_err/2, config_err/2]). 29 30 31%%----------------------------------------------------------------- 32%% This function is called when there is an error in a user 33%% supplied item, e.g. instrumentation function. 34%%----------------------------------------------------------------- 35user_err(F, A) -> 36 report_err(user_err, F, A). 37 38 39%%----------------------------------------------------------------- 40%% This function is called when there is a configuration error, 41%% either at startup (in a conf-file) or at run-time (e.g. when 42%% information in the configuration tables are inconsistent.) 43%%----------------------------------------------------------------- 44config_err(F, A) -> 45 report_err(config_err, F, A). 46 47 48%% ----------------------------------------------------------------- 49 50 51report_err(Func, Format, Args) -> 52 case report_module() of 53 {ok, Mod} -> 54 (catch Mod:Func(Format, Args)); 55 _ -> 56 ok 57 end. 58 59 60 61report_module() -> 62 case (catch ets:lookup(snmp_agent_table, error_report_mod)) of 63 [{error_report_mod, Mod}] -> 64 {ok, Mod}; 65 _ -> 66 error 67 end. 68