Datei: NDOInterfaces/NDOException.cs
Last Commit (831b962)
| 1 | // |
| 2 | // Copyright (c) 2002-2019 Mirko Matytschak |
| 3 | // (www.netdataobjects.de) |
| 4 | // |
| 5 | // Author: Mirko Matytschak |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
| 11 | // conditions: |
| 12 | |
| 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 14 | // of the Software. |
| 15 | // |
| 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | |
| 23 | using System; |
| 24 | using System.Runtime.Serialization; |
| 25 | |
| 26 | namespace NDO |
| 27 | { |
| 28 | ····/// <summary> |
| 29 | ····/// This exception type will be thrown by the NDO framework, if errors occure. |
| 30 | ····/// </summary> |
| 31 | ····[Serializable] |
| 32 | public class NDOException : Exception, ISerializable |
| 33 | ····{ |
| 34 | ········int errorNumber; |
| 35 | |
| 36 | ········/// <summary> |
| 37 | ········/// Gets the error number of the NDOException. See the <see href="ExceptionNumbers.html">documentation</see> for information about the error numbers. |
| 38 | ········/// </summary> |
| 39 | ········public int ErrorNumber |
| 40 | ········{ |
| 41 | ············get { return errorNumber; } |
| 42 | ········} |
| 43 | |
| 44 | |
| 45 | ········/// <summary> |
| 46 | ········/// Constructor |
| 47 | ········/// </summary> |
| 48 | ········/// <param name="errorNumber">A unique number, which denotes the cause of the exception.</param> |
| 49 | ········/// <param name="s">The message string of the exception.</param> |
| 50 | ········public NDOException(int errorNumber, string s) : base(s) |
| 51 | ········{ |
| 52 | ············this.errorNumber = errorNumber; |
| 53 | ········} |
| 54 | |
| 55 | ········/// <summary> |
| 56 | ········/// Constructs a NDOException object. |
| 57 | ········/// </summary> |
| 58 | ········/// <param name="errorNumber">The uniqe error code.</param> |
| 59 | ········/// <param name="s">The message string of the exception.</param> |
| 60 | ········/// <param name="innerException"></param> |
| 61 | ········public NDOException(int errorNumber, string s, Exception innerException) : base(s, innerException) |
| 62 | ········{ |
| 63 | ············this.errorNumber = errorNumber; |
| 64 | ········} |
| 65 | |
| 66 | ········/// <summary> |
| 67 | ········/// This constructor is used while deserializing an NDOException object. |
| 68 | ········/// </summary> |
| 69 | ········/// <param name="info">The SerializationInfo containing the data, the object is serialized from.</param> |
| 70 | ········/// <param name="context">The source if this serialization.</param> |
| 71 | ········protected NDOException(SerializationInfo info, StreamingContext context) : base(info, context) |
| 72 | ········{ |
| 73 | ············//············string key = (string) info.GetValue("Key", typeof(string)); |
| 74 | ············this.errorNumber = (int) info.GetValue("errorNumber", typeof(int)); |
| 75 | ········} |
| 76 | |
| 77 | ········/// <summary> |
| 78 | ········/// Populates a SerializationInfo with the data needed to serialize the target object. |
| 79 | ········/// </summary> |
| 80 | ········/// <param name="info">The SerializationInfo to populate with data. </param> |
| 81 | ········/// <param name="context">The destination for this serialization.</param> |
| 82 | ········public override void GetObjectData(SerializationInfo info, StreamingContext context) |
| 83 | ········{ |
| 84 | ············base.GetObjectData(info, context); |
| 85 | ············info.AddValue("errorNumber", this.errorNumber); |
| 86 | ········} |
| 87 | |
| 88 | ········/// <summary> |
| 89 | ········/// Overridden. Creates and returns a string representation of the current exception. |
| 90 | ········/// </summary> |
| 91 | ········/// <returns></returns> |
| 92 | ········public override string ToString() |
| 93 | ········{ |
| 94 | ············string s = base.ToString (); |
| 95 | ············int p = s.IndexOf(":"); |
| 96 | ············if (p > -1) |
| 97 | ············{ |
| 98 | ················return s.Substring(0, p + 2) + "#" + errorNumber + " " + s.Substring(p + 2); |
| 99 | ············} |
| 100 | ············else |
| 101 | ················return s; |
| 102 | ········} |
| 103 | |
| 104 | ····} |
| 105 | } |
| 106 |
New Commit (add8490)
| 1 | // |
| 2 | // Copyright (c) 2002-2019 Mirko Matytschak |
| 3 | // (www.netdataobjects.de) |
| 4 | // |
| 5 | // Author: Mirko Matytschak |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
| 9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
| 10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
| 11 | // conditions: |
| 12 | |
| 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
| 14 | // of the Software. |
| 15 | // |
| 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | |
| 23 | using System; |
| 24 | using System.Runtime.Serialization; |
| 25 | |
| 26 | namespace NDO |
| 27 | { |
| 28 | ····/// <summary> |
| 29 | ····/// This exception type will be thrown by the NDO framework, if errors occure. |
| 30 | ····/// </summary> |
| 31 | ····[Serializable] |
| 32 | public class NDOException : Exception |
| 33 | ····{ |
| 34 | ········int errorNumber; |
| 35 | |
| 36 | ········/// <summary> |
| 37 | ········/// Gets the error number of the NDOException. See the <see href="ExceptionNumbers.html">documentation</see> for information about the error numbers. |
| 38 | ········/// </summary> |
| 39 | ········public int ErrorNumber |
| 40 | ········{ |
| 41 | ············get { return errorNumber; } |
| 42 | ········} |
| 43 | |
| 44 | |
| 45 | ········/// <summary> |
| 46 | ········/// Constructor |
| 47 | ········/// </summary> |
| 48 | ········/// <param name="errorNumber">A unique number, which denotes the cause of the exception.</param> |
| 49 | ········/// <param name="s">The message string of the exception.</param> |
| 50 | ········public NDOException(int errorNumber, string s) : base(s) |
| 51 | ········{ |
| 52 | ············this.errorNumber = errorNumber; |
| 53 | ········} |
| 54 | |
| 55 | ········/// <summary> |
| 56 | ········/// Constructs a NDOException object. |
| 57 | ········/// </summary> |
| 58 | ········/// <param name="errorNumber">The uniqe error code.</param> |
| 59 | ········/// <param name="s">The message string of the exception.</param> |
| 60 | ········/// <param name="innerException"></param> |
| 61 | ········public NDOException(int errorNumber, string s, Exception innerException) : base(s, innerException) |
| 62 | ········{ |
| 63 | ············this.errorNumber = errorNumber; |
| 64 | ········} |
| 65 | |
| 66 | ········/// <summary> |
| 67 | ········/// Overridden. Creates and returns a string representation of the current exception. |
| 68 | ········/// </summary> |
| 69 | ········/// <returns></returns> |
| 70 | ········public override string ToString() |
| 71 | ········{ |
| 72 | ············string s = base.ToString (); |
| 73 | ············int p = s.IndexOf(":"); |
| 74 | ············if (p > -1) |
| 75 | ············{ |
| 76 | ················return s.Substring(0, p + 2) + "#" + errorNumber + " " + s.Substring(p + 2); |
| 77 | ············} |
| 78 | ············else |
| 79 | ················return s; |
| 80 | ········} |
| 81 | |
| 82 | ····} |
| 83 | } |
| 84 |