diff --git a/plist-cil/NSObject.cs b/plist-cil/NSObject.cs index ad216e1..0c2708b 100644 --- a/plist-cil/NSObject.cs +++ b/plist-cil/NSObject.cs @@ -373,7 +373,7 @@ namespace Claunia.PropertyList } catch (IOException) { - throw new SystemException("The given object of class " + o.GetType() + " could not be serialized and stored in a NSData object."); + throw new PropertyListException("The given object of class " + o.GetType() + " could not be serialized and stored in a NSData object."); } } diff --git a/plist-cil/NSString.cs b/plist-cil/NSString.cs index f2b7230..5e50103 100644 --- a/plist-cil/NSString.cs +++ b/plist-cil/NSString.cs @@ -163,7 +163,7 @@ namespace Claunia.PropertyList } catch (Exception ex) { - throw new SystemException("Could not encode the NSString into UTF-8: " + ex.Message); + throw new PropertyListException("Could not encode the NSString into UTF-8: " + ex.Message); } } diff --git a/plist-cil/PropertyListException.cs b/plist-cil/PropertyListException.cs new file mode 100644 index 0000000..75085d5 --- /dev/null +++ b/plist-cil/PropertyListException.cs @@ -0,0 +1,77 @@ +// plist-cil - An open source library to parse and generate property lists for .NET +// Copyright (C) 2015 Natalia Portillo +// Copyright (C) 2016 Quamotion +// +// This code is based on: +// plist - An open source library to parse and generate property lists +// Copyright (C) 2014 Daniel Dreibrodt +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +using System; +using System.Runtime.Serialization; + +namespace Claunia.PropertyList +{ + /// + /// The exception that is thrown when an property list file could not be processed correctly. + /// + [Serializable] + public class PropertyListException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public PropertyListException() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error message that explains the reason for the exception. + /// + public PropertyListException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The error message that explains the reason for the exception. + /// + /// + /// The exception that is the cause of the current exception, or + /// if no inner exception is specified. + /// + public PropertyListException(string message, Exception inner) + : base(message, inner) + { + } + +#if !NETCORE + protected PropertyListException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } +#endif + } +} diff --git a/plist-cil/PropertyListFormatException.cs b/plist-cil/PropertyListFormatException.cs index 3a8ff50..c7377d7 100644 --- a/plist-cil/PropertyListFormatException.cs +++ b/plist-cil/PropertyListFormatException.cs @@ -32,7 +32,7 @@ namespace Claunia.PropertyList /// /// @author Daniel Dreibrodt /// @author Natalia Portillo - public class PropertyListFormatException : Exception + public class PropertyListFormatException : PropertyListException { /// /// Creates a new exception with the given message.