• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lextudio / sharpsnmplib / 19051900654

03 Nov 2025 10:45PM UTC coverage: 53.074% (+0.09%) from 52.986%
19051900654

push

github

lextm
Replace OperationException with ErrorException for response error handling in SNMP message extensions

874 of 1881 branches covered (46.46%)

Branch coverage included in aggregate %.

0 of 6 new or added lines in 2 files covered. (0.0%)

3 existing lines in 1 file now uncovered.

2389 of 4267 relevant lines covered (55.99%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/SharpSnmpLib/OperationException.cs
1
// Operation exception type.
2
// Copyright (C) 2008-2010 Malcolm Crowe, Lex Li, and other contributors.
3
// 
4
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
5
// software and associated documentation files (the "Software"), to deal in the Software
6
// without restriction, including without limitation the rights to use, copy, modify, merge,
7
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
8
// to whom the Software is furnished to do so, subject to the following conditions:
9
// 
10
// The above copyright notice and this permission notice shall be included in all copies or
11
// substantial portions of the Software.
12
// 
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
15
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
16
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
// DEALINGS IN THE SOFTWARE.
19

20
/*
21
 * Created by SharpDevelop.
22
 * User: lextm
23
 * Date: 2008/4/23
24
 * Time: 19:40
25
 * 
26
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
27
 */
28
using System;
29
using System.Globalization;
30
using System.Net;
31
using System.Runtime.Serialization;
32

33
namespace Lextm.SharpSnmpLib
34
{
35
    /// <summary>
36
    /// Operation exception of #SNMP.
37
    /// </summary>
38
    [Serializable]
39
    public class OperationException : SnmpException, ISerializable
40
    {
41
        /// <summary>
42
        /// Agent address.
43
        /// </summary>
44
        public IPAddress? Agent { get; set; }
45

46
        /// <summary>
47
        /// Creates a <see cref="OperationException"/> instance.
48
        /// </summary>
49
        public OperationException()
1✔
50
        {
51
        }
1✔
52

53
        /// <summary>
54
        /// Creates a <see cref="OperationException"/> instance with a specific <see cref="string"/>.
55
        /// </summary>
56
        /// <param name="message"></param>
57
        public OperationException(string message) : base(message)
1✔
58
        {
59
        }
1✔
60

61
        /// <summary>
62
        /// Creates a <see cref="OperationException"/> instance with a specific <see cref="string"/> and an <see cref="Exception"/>.
63
        /// </summary>
64
        /// <param name="message"></param>
65
        /// <param name="inner"></param>
66
        public OperationException(string message, Exception inner) : base(message, inner)
1✔
67
        {
68
        }
1✔
69

70
        /// <summary>
71
        /// Creates a <see cref="OperationException"/> instance.
72
        /// </summary>
73
        /// <param name="info">Info</param>
74
        /// <param name="context">Context</param>
75
        protected OperationException(SerializationInfo info, StreamingContext context)
76
           : base(info, context)
1✔
77
        {
78
            var content = info.GetString("Agent");
1✔
79
            if (content == null)
1!
80
            {
81
                return;
1✔
82
            }
83

UNCOV
84
            Agent = IPAddress.Parse(content);
×
UNCOV
85
        }
×
86

87
        /// <inheritdoc/>
88
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
89
        {
90
            base.GetObjectData(info, context);
1✔
91
            info.AddValue("Agent", Agent?.ToString());
1✔
92
        }
1✔
93

94
        /// <summary>
95
        /// Details on operation.
96
        /// </summary>
UNCOV
97
        protected override string Details => string.Format(CultureInfo.InvariantCulture, "{0}. Agent: {1}", Message, Agent);
×
98

99
        /// <summary>
100
        /// Creates a <see cref="OperationException"/> with a specific <see cref="IPAddress"/>.
101
        /// </summary>
102
        /// <param name="message">Message</param>
103
        /// <param name="agent">Agent address</param>
104
        public static OperationException Create(string message, IPAddress agent)
105
        {
106
            var ex = new OperationException(message) { Agent = agent };
1✔
107
            return ex;
1✔
108
        }
109
    }
110
}
111

112
// generate OperationExceptionTestFixture class that contains test cases for OperationException
113

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc