Search Results for

    Show / Hide Table of Contents

    Class PostgresException

    The exception that is thrown when the PostgreSQL backend reports errors (e.g. query SQL issues, constraint violations).

    Inheritance
    Object
    Exception
    SystemException
    ExternalException
    DbException
    NpgsqlException
    PostgresException
    Implements
    ISerializable
    Inherited Members
    NpgsqlException.BatchCommand
    ExternalException.ErrorCode
    Exception.GetBaseException()
    Exception.GetType()
    Exception.Data
    Exception.HelpLink
    Exception.HResult
    Exception.InnerException
    Exception.Message
    Exception.Source
    Exception.StackTrace
    Exception.TargetSite
    Exception.SerializeObjectState
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    [Serializable]
    public sealed class PostgresException : NpgsqlException, ISerializable
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    Constructors

    | Improve this Doc View Source

    PostgresException(String, String, String, String, String, String, Int32, Int32, String, String, String, String, String, String, String, String, String, String)

    Creates a new instance.

    Declaration
    public PostgresException(string messageText, string severity, string invariantSeverity, string sqlState, string detail = null, string hint = null, int position = 0, int internalPosition = 0, string internalQuery = null, string where = null, string schemaName = null, string tableName = null, string columnName = null, string dataTypeName = null, string constraintName = null, string file = null, string line = null, string routine = null)
    Parameters
    Type Name Description
    String messageText
    String severity
    String invariantSeverity
    String sqlState
    String detail
    String hint
    Int32 position
    Int32 internalPosition
    String internalQuery
    String where
    String schemaName
    String tableName
    String columnName
    String dataTypeName
    String constraintName
    String file
    String line
    String routine
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    PostgresException(String, String, String, String)

    Creates a new instance.

    Declaration
    public PostgresException(string messageText, string severity, string invariantSeverity, string sqlState)
    Parameters
    Type Name Description
    String messageText
    String severity
    String invariantSeverity
    String sqlState
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    Properties

    | Improve this Doc View Source

    Code

    The SQLSTATE code for the error.

    Declaration
    [Obsolete("Use SqlState instead")]
    public string Code { get; }
    Property Value
    Type Description
    String
    Remarks

    Always present. Constants are defined in PostgresErrorCodes. See https://www.postgresql.org/docs/current/static/errcodes-appendix.html

    | Improve this Doc View Source

    ColumnName

    If the error was associated with a specific table column, the name of the column. (Refer to the schema and table name fields to identify the table.)

    Declaration
    public string ColumnName { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    ConstraintName

    If the error was associated with a specific constraint, the name of the constraint. Refer to fields listed above for the associated table or domain. (For this purpose, indexes are treated as constraints, even if they weren't created with constraint syntax.)

    Declaration
    public string ConstraintName { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    DataTypeName

    If the error was associated with a specific data type, the name of the data type. (Refer to the schema name field for the name of the data type's schema.)

    Declaration
    public string DataTypeName { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    Detail

    An optional secondary error message carrying more detail about the problem. May run to multiple lines.

    Declaration
    public string Detail { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    File

    The file name of the source-code location where the error was reported.

    Declaration
    public string File { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    Hint

    An optional suggestion what to do about the problem. This is intended to differ from Detail in that it offers advice (potentially inappropriate) rather than hard facts. May run to multiple lines.

    Declaration
    public string Hint { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    InternalPosition

    This is defined the same as the Position field, but it is used when the cursor position refers to an internally generated command rather than the one submitted by the client. The InternalQuery field will always appear when this field appears. 0 means not provided.

    Declaration
    public int InternalPosition { get; }
    Property Value
    Type Description
    Int32
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    InternalQuery

    The text of a failed internally-generated command. This could be, for example, a SQL query issued by a PL/pgSQL function.

    Declaration
    public string InternalQuery { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    InvariantSeverity

    Severity of the error or notice, not localized. Always present since PostgreSQL 9.6.

    Declaration
    public string InvariantSeverity { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    IsTransient

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

    Declaration
    public override bool IsTransient { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    NpgsqlException.IsTransient
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    Line

    The line number of the source-code location where the error was reported.

    Declaration
    public string Line { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    MessageText

    The primary human-readable error message. This should be accurate but terse.

    Declaration
    public string MessageText { get; }
    Property Value
    Type Description
    String
    Remarks

    Always present.

    | Improve this Doc View Source

    Position

    The field value is a decimal ASCII integer, indicating an error cursor position as an index into the original query string. The first character has index 1, and positions are measured in characters not bytes. 0 means not provided.

    Declaration
    public int Position { get; }
    Property Value
    Type Description
    Int32
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    Routine

    The name of the source-code routine reporting the error.

    Declaration
    public string Routine { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    SchemaName

    If the error was associated with a specific database object, the name of the schema containing that object, if any.

    Declaration
    public string SchemaName { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    Severity

    Severity of the error or notice. Always present.

    Declaration
    public string Severity { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    SqlState

    The SQLSTATE code for the error.

    Declaration
    public string SqlState { get; }
    Property Value
    Type Description
    String
    Remarks

    Always present. Constants are defined in PostgresErrorCodes. See https://www.postgresql.org/docs/current/static/errcodes-appendix.html

    | Improve this Doc View Source

    TableName

    Table name: if the error was associated with a specific table, the name of the table. (Refer to the schema name field for the name of the table's schema.)

    Declaration
    public string TableName { get; }
    Property Value
    Type Description
    String
    Remarks

    PostgreSQL 9.3 and up.

    | Improve this Doc View Source

    Where

    An indication of the context in which the error occurred. Presently this includes a call stack traceback of active PL functions. The trace is one entry per line, most recent first.

    Declaration
    public string Where { get; }
    Property Value
    Type Description
    String
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    Methods

    | Improve this Doc View Source

    GetObjectData(SerializationInfo, StreamingContext)

    Populates a SerializationInfo with the data needed to serialize the target object.

    Declaration
    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info

    The SerializationInfo to populate with data.

    StreamingContext context

    The destination (see StreamingContext) for this serialization.

    Overrides
    Exception.GetObjectData(SerializationInfo, StreamingContext)
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    | Improve this Doc View Source

    ToString()

    The exception that is thrown when the PostgreSQL backend reports errors (e.g. query SQL issues, constraint violations).

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    ExternalException.ToString()
    Remarks

    This exception only corresponds to a PostgreSQL-delivered error. Other errors (e.g. network issues) will be raised via NpgsqlException, and purely Npgsql-related issues which aren't related to the server will be raised via the standard CLR exceptions (e.g. ArgumentException).

    See https://www.postgresql.org/docs/current/static/errcodes-appendix.html, https://www.postgresql.org/docs/current/static/protocol-error-fields.html

    Implements

    System.Runtime.Serialization.ISerializable
    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team