Table of Contents

Class NpgsqlException

Namespace
Npgsql
Assembly
Npgsql.dll

The exception that is thrown when server-related issues occur.

[Serializable]
public class NpgsqlException : DbException, ISerializable
Inheritance
NpgsqlException
Implements
Derived
Inherited Members

Remarks

PostgreSQL errors (e.g. query SQL issues, constraint violations) are raised via PostgresException 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).

Constructors

NpgsqlException()

Initializes a new instance of the NpgsqlException class.

public NpgsqlException()

NpgsqlException(SerializationInfo, StreamingContext)

Initializes a new instance of the NpgsqlException class with serialized data.

[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
protected NpgsqlException(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

The SerializationInfo that holds the serialized object data about the exception being thrown.

context StreamingContext

The StreamingContext that contains contextual information about the source or destination.

NpgsqlException(string?)

Initializes a new instance of the NpgsqlException class with a specified error message.

public NpgsqlException(string? message)

Parameters

message string

The message that describes the error.

NpgsqlException(string?, Exception?)

Initializes a new instance of the NpgsqlException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public NpgsqlException(string? message, Exception? innerException)

Parameters

message string

The error message that explains the reason for the exception.

innerException 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.

Properties

BatchCommand

If this DbException was thrown when executing a DbBatch, references the specific DbBatchCommand which triggered the exception.

public NpgsqlBatchCommand? BatchCommand { get; set; }

Property Value

NpgsqlBatchCommand

The specific DbBatchCommand which triggered the exception.

DbBatchCommand

When overridden in a derived class, if this DbException was thrown when executing a DbBatch, references the specific DbBatchCommand which triggered the exception.

protected override DbBatchCommand? DbBatchCommand { get; }

Property Value

DbBatchCommand

The specific DbBatchCommand which triggered the exception.

IsTransient

Specifies whether the exception is considered transient, that is, whether retrying the operation could succeed (e.g. a network error or a timeout).

public override bool IsTransient { get; }

Property Value

bool