Код: Выделить всё
///
/// The exception that is thrown when the time allotted for talking to the FANUC controller has expired.
///
[Serializable]
public class FanucTimeoutException : TimeoutException
{
///
/// Initializes a new instance of the FanucLib.FanucTimeoutException class.
///
public FanucTimeoutException() { }
///
/// Initializes a new instance of the FanucLib.FanucTimeoutException class with the specified error message.
///
/// The message that describes the error.
public FanucTimeoutException(string message) : base(message)
{
}
///
/// Initializes a new instance of the FanucLib.FanucTimeoutException class with the specified error message and the address trying to access.
///
/// The message that describes the error.
/// The address trying to access.
public FanucTimeoutException(string message, string address) : base($"{message} Address: {address}.")
{
}
///
/// Initializes a new instance of the FanucLib.FanucTimeoutException class with
/// a specified error message and a reference to the inner exception that is the
/// cause of this exception.
///
/// The error message that explains the reason for the exception.
/// The exception that is the cause of the current exception. If the innerException
/// parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.
public FanucTimeoutException(string message, Exception innerException) : base(message, innerException)
{
}
///
/// Initializes a new instance of the FanucLib.FanucTimeoutException class with
/// a specified error message, the address trying to access and a reference to the inner exception that is the
/// cause of this exception.
///
/// The error message that explains the reason for the exception.
/// The address trying to access.
/// The exception that is the cause of the current exception. If the innerException
/// parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.
public FanucTimeoutException(string message, string address, Exception innerException) : base($"{message} Address: {address}.", innerException)
{
}
///
public FanucTimeoutException(SerializationInfo info, StreamingContext context)
{
}
}
< /code>
Однако я не уверен, является ли хорошей практикой бросить TimeoutException < /code>. Руководство C# и .NET по дизайну исключений не говорите о TimeOutException Я ограничен только использованием этих предлагаемых типов исключений или у меня есть свобода использовать полный диапазон, за исключением тех, которые рекомендуются в руководстве? < /p>
Подробнее здесь: https://stackoverflow.com/questions/522 ... d-practice