From 4df6273c95f3f6f259971abe715bdd570e267281 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 10 Oct 2015 14:50:28 +0200 Subject: [PATCH] changes concerning exception handling --- Snmp2Mysql/Program.cs | 18 ++++++++++++------ Snmp2Mysql/SnmpGetter.cs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Snmp2Mysql/Program.cs b/Snmp2Mysql/Program.cs index 7127aa9..c04d3a6 100644 --- a/Snmp2Mysql/Program.cs +++ b/Snmp2Mysql/Program.cs @@ -35,12 +35,18 @@ namespace Snmp2Mysql } } - SnmpGetterResultProvider res = snmpGetter.Exec(); - foreach (SnmpGetterResult r in res) - { - Console.WriteLine("{0} {1} {2}: {3}", r.Index, r.Oid, r.Type, r.Value); - dc.add((int)r.Index, r.Value); - } + try + { + SnmpGetterResultProvider res = snmpGetter.Exec(); + foreach (SnmpGetterResult r in res) + { + Console.WriteLine("{0} {1} {2}: {3}", r.Index, r.Oid, r.Type, r.Value); + dc.add((int)r.Index, r.Value); + } + } + catch (SnmpGetterException e) { + Console.WriteLine ("no result: {0}", e.Message); + } } } } diff --git a/Snmp2Mysql/SnmpGetter.cs b/Snmp2Mysql/SnmpGetter.cs index 46bf598..848687a 100644 --- a/Snmp2Mysql/SnmpGetter.cs +++ b/Snmp2Mysql/SnmpGetter.cs @@ -140,7 +140,7 @@ namespace Snmp2Mysql { mPacket = (SnmpV2Packet)mTarget.Request(mPdu, mParams); } - catch (SnmpNetworkException e) + catch (SnmpException e) { throw new SnmpGetterException(e.Message, e); }