// // FolderNotFoundException.cs // // Author: Jeffrey Stedfast // // Copyright (c) 2013-2020 .NET Foundation and Contributors // // 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; #if SERIALIZABLE using System.Security; using System.Runtime.Serialization; #endif namespace MailKit { /// /// The exception that is thrown when a folder could not be found. /// /// /// This exception is thrown by . /// #if SERIALIZABLE [Serializable] #endif public class FolderNotFoundException : Exception { #if SERIALIZABLE /// /// Initializes a new instance of the class. /// /// /// Deserializes a . /// /// The serialization info. /// The streaming context. /// /// is null. /// protected FolderNotFoundException (SerializationInfo info, StreamingContext context) : base (info, context) { FolderName = info.GetString ("FolderName"); } #endif /// /// Initializes a new instance of the class. /// /// /// Creates a new . /// /// The error message. /// The name of the folder. /// The inner exception. /// /// is null. /// public FolderNotFoundException (string message, string folderName, Exception innerException) : base (message, innerException) { if (folderName == null) throw new ArgumentNullException (nameof (folderName)); FolderName = folderName; } /// /// Initializes a new instance of the class. /// /// /// Creates a new . /// /// The error message. /// The name of the folder. /// /// is null. /// public FolderNotFoundException (string message, string folderName) : base (message) { if (folderName == null) throw new ArgumentNullException (nameof (folderName)); FolderName = folderName; } /// /// Initializes a new instance of the class. /// /// /// Creates a new . /// /// The name of the folder. /// /// is null. /// public FolderNotFoundException (string folderName) : this ("The requested folder could not be found.", folderName) { } /// /// Gets the name of the folder that could not be found. /// /// /// Gets the name of the folder that could not be found. /// /// The name of the folder. public string FolderName { get; private set; } #if SERIALIZABLE /// /// When overridden in a derived class, sets the /// with information about the exception. /// /// /// Serializes the state of the . /// /// The serialization info. /// The streaming context. /// /// is null. /// [SecurityCritical] public override void GetObjectData (SerializationInfo info, StreamingContext context) { base.GetObjectData (info, context); info.AddValue ("FolderName", FolderName); } #endif } }