using System;
using System.Data.Common;
using System.IO;
using System.Net.Sockets;
using System.Runtime.Serialization;
namespace Npgsql
{
///
/// The exception that is thrown when server-related issues occur.
///
///
/// PostgreSQL errors (e.g. query SQL issues, constraint violations) are raised via
/// which is a subclass of this class.
/// Purely Npgsql-related issues which aren't related to the server will be raised
/// via the standard CLR exceptions (e.g. ArgumentException).
///
[Serializable]
public class NpgsqlException : DbException
{
///
/// Initializes a new instance of the class.
///
public NpgsqlException() {}
///
/// Initializes a new instance of the 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, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
public NpgsqlException(string message, Exception innerException)
: base(message, innerException) {}
///
/// Initializes a new instance of the class with a specified error message.
///
/// The message that describes the error.
public NpgsqlException(string message)
: base(message) { }
///
/// Specifies whether the exception is considered transient, that is, whether retrying to operation could
/// succeed (e.g. a network error).
///
public virtual bool IsTransient =>
InnerException is IOException || InnerException is SocketException;
#region Serialization
///
/// Initializes a new instance of the class with serialized data.
///
/// The SerializationInfo that holds the serialized object data about the exception being thrown.
/// The StreamingContext that contains contextual information about the source or destination.
protected internal NpgsqlException(SerializationInfo info, StreamingContext context) : base(info, context) {}
#endregion
}
}