//******************************************************************************************************
// FtpExceptions.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 05/22/2003 - J. Ritchie Carroll
// Generated original version of source code.
// 09/14/2009 - Stephen C. Wills
// Added new header and license agreement.
// 12/17/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
#region [ Contributor License Agreements ]
//*******************************************************************************************************
//
// Code based on the following project:
// http://www.codeproject.com/KB/IP/net_ftp_upload.aspx
//
// Copyright Alex Kwok & Uwe Keim
//
// The Code Project Open License (CPOL):
// http://www.codeproject.com/info/cpol10.aspx
//
//*******************************************************************************************************
#endregion
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace GSF.Net.Ftp
{
///
/// FTP exception base class.
///
[Serializable]
public abstract class FtpExceptionBase : Exception
{
private readonly FtpResponse m_ftpResponse;
internal FtpExceptionBase(string message)
: base(message)
{
}
internal FtpExceptionBase(string message, FtpExceptionBase inner)
: base(message, inner)
{
}
internal FtpExceptionBase(string message, FtpResponse ftpResponse)
: base(message)
{
m_ftpResponse = ftpResponse;
}
///
/// Response message related to exception, if any.
///
public string ResponseMessage
{
get
{
if (m_ftpResponse != null)
return m_ftpResponse.Message;
return "";
}
}
///
/// Deserializes the .
///
/// The to populate with data.
/// The destination for this serialization.
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
///
/// Invalid FTP response exception.
///
[Serializable]
public class FtpInvalidResponseException : FtpExceptionBase
{
internal FtpInvalidResponseException(string message, FtpResponse ftpResponse)
: base(message, ftpResponse)
{
}
}
///
/// FTP authentication exception.
///
[Serializable]
public class FtpAuthenticationException : FtpExceptionBase
{
internal FtpAuthenticationException(string message, FtpResponse ftpResponse)
: base(message, ftpResponse)
{
}
}
///
/// FTP file not found exception.
///
[Serializable]
public class FtpFileNotFoundException : FtpExceptionBase
{
internal FtpFileNotFoundException(string remoteFile)
: base($"Remote file ({remoteFile}) not found. Try refreshing the directory.")
{
}
}
///
/// FTP server down exception.
///
[Serializable]
public class FtpServerDownException : FtpExceptionBase
{
internal FtpServerDownException(FtpResponse ftpResponse)
: this("FTP service was down.", ftpResponse)
{
}
internal FtpServerDownException(string message, FtpResponse ftpResponse)
: base(message, ftpResponse)
{
}
}
///
/// FTP command exception.
///
[Serializable]
public class FtpCommandException : FtpExceptionBase
{
internal FtpCommandException(string message, FtpResponse ftpResponse)
: base(message, ftpResponse)
{
}
}
///
/// FTP data transfer exception.
///
[Serializable]
public class FtpDataTransferException : FtpExceptionBase
{
internal FtpDataTransferException()
: base("Data transfer error: previous transfer not finished.")
{
}
internal FtpDataTransferException(string message, FtpResponse ftpResponse)
: base(message, ftpResponse)
{
}
}
///
/// FTP user abort exception.
///
[Serializable]
public class FtpUserAbortException : FtpExceptionBase
{
internal FtpUserAbortException()
: base("File Transfer aborted by user.")
{
}
}
///
/// FTP resume not supported exception.
///
[Serializable]
public class FtpResumeNotSupportedException : FtpExceptionBase
{
internal FtpResumeNotSupportedException(FtpResponse ftpResponse)
: base("Data transfer error: server does not support resuming.", ftpResponse)
{
}
}
}