pg-error-constants
PostgresQL error constants for use with Node.js. Use these to avoid code like `if (err.code === '23505')` and instead write `if (err.code === UNIQUE_VIOLATION)`.
Last updated 3 years ago by linusu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pg-error-constants 
SYNC missed versions from official npm registry.

PG Error Constants

PostgresQL error constants for use with Node.js. Use these to avoid code like if (err.code === '23505') and instead write if (err.code === UNIQUE_VIOLATION).

Installation

npm install --save pg-error-constants

Usage

const { UNIQUE_VIOLATION } = require('pg-error-constants')

// ...
  .catch((err) => {
    if (err.code === UNIQUE_VIOLATION && err.constraint === 'user_name_key') {
      throw new UserError('That name is already taken')
    }

    throw err
  })

Constants

Error Code Constant name
Class 00 — Successful Completion
00000 SUCCESSFUL_COMPLETION
Class 01 — Warning
01000 WARNING
0100C DYNAMIC_RESULT_SETS_RETURNED
01008 IMPLICIT_ZERO_BIT_PADDING
01003 NULL_VALUE_ELIMINATED_IN_SET_FUNCTION
01007 PRIVILEGE_NOT_GRANTED
01006 PRIVILEGE_NOT_REVOKED
01004 STRING_DATA_RIGHT_TRUNCATION
01P01 DEPRECATED_FEATURE
Class 02 — No Data (this is also a warning class per the SQL standard)
02000 NO_DATA
02001 NO_ADDITIONAL_DYNAMIC_RESULT_SETS_RETURNED
Class 03 — SQL Statement Not Yet Complete
03000 SQL_STATEMENT_NOT_YET_COMPLETE
Class 08 — Connection Exception
08000 CONNECTION_EXCEPTION
08003 CONNECTION_DOES_NOT_EXIST
08006 CONNECTION_FAILURE
08001 SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION
08004 SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION
08007 TRANSACTION_RESOLUTION_UNKNOWN
08P01 PROTOCOL_VIOLATION
Class 09 — Triggered Action Exception
09000 TRIGGERED_ACTION_EXCEPTION
Class 0A — Feature Not Supported
0A000 FEATURE_NOT_SUPPORTED
Class 0B — Invalid Transaction Initiation
0B000 INVALID_TRANSACTION_INITIATION
Class 0F — Locator Exception
0F000 LOCATOR_EXCEPTION
0F001 INVALID_LOCATOR_SPECIFICATION
Class 0L — Invalid Grantor
0L000 INVALID_GRANTOR
0LP01 INVALID_GRANT_OPERATION
Class 0P — Invalid Role Specification
0P000 INVALID_ROLE_SPECIFICATION
Class 0Z — Diagnostics Exception
0Z000 DIAGNOSTICS_EXCEPTION
0Z002 STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER
Class 20 — Case Not Found
20000 CASE_NOT_FOUND
Class 21 — Cardinality Violation
21000 CARDINALITY_VIOLATION
Class 22 — Data Exception
22000 DATA_EXCEPTION
2202E ARRAY_SUBSCRIPT_ERROR
22021 CHARACTER_NOT_IN_REPERTOIRE
22008 DATETIME_FIELD_OVERFLOW
22012 DIVISION_BY_ZERO
22005 ERROR_IN_ASSIGNMENT
2200B ESCAPE_CHARACTER_CONFLICT
22022 INDICATOR_OVERFLOW
22015 INTERVAL_FIELD_OVERFLOW
2201E INVALID_ARGUMENT_FOR_LOGARITHM
22014 INVALID_ARGUMENT_FOR_NTILE_FUNCTION
22016 INVALID_ARGUMENT_FOR_NTH_VALUE_FUNCTION
2201F INVALID_ARGUMENT_FOR_POWER_FUNCTION
2201G INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION
22018 INVALID_CHARACTER_VALUE_FOR_CAST
22007 INVALID_DATETIME_FORMAT
22019 INVALID_ESCAPE_CHARACTER
2200D INVALID_ESCAPE_OCTET
22025 INVALID_ESCAPE_SEQUENCE
22P06 NONSTANDARD_USE_OF_ESCAPE_CHARACTER
22010 INVALID_INDICATOR_PARAMETER_VALUE
22023 INVALID_PARAMETER_VALUE
2201B INVALID_REGULAR_EXPRESSION
2201W INVALID_ROW_COUNT_IN_LIMIT_CLAUSE
2201X INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE
22009 INVALID_TIME_ZONE_DISPLACEMENT_VALUE
2200C INVALID_USE_OF_ESCAPE_CHARACTER
2200G MOST_SPECIFIC_TYPE_MISMATCH
22004 NULL_VALUE_NOT_ALLOWED
22002 NULL_VALUE_NO_INDICATOR_PARAMETER
22003 NUMERIC_VALUE_OUT_OF_RANGE
22026 STRING_DATA_LENGTH_MISMATCH
22001 STRING_DATA_RIGHT_TRUNCATION
22011 SUBSTRING_ERROR
22027 TRIM_ERROR
22024 UNTERMINATED_C_STRING
2200F ZERO_LENGTH_CHARACTER_STRING
22P01 FLOATING_POINT_EXCEPTION
22P02 INVALID_TEXT_REPRESENTATION
22P03 INVALID_BINARY_REPRESENTATION
22P04 BAD_COPY_FILE_FORMAT
22P05 UNTRANSLATABLE_CHARACTER
2200L NOT_AN_XML_DOCUMENT
2200M INVALID_XML_DOCUMENT
2200N INVALID_XML_CONTENT
2200S INVALID_XML_COMMENT
2200T INVALID_XML_PROCESSING_INSTRUCTION
Class 23 — Integrity Constraint Violation
23000 INTEGRITY_CONSTRAINT_VIOLATION
23001 RESTRICT_VIOLATION
23502 NOT_NULL_VIOLATION
23503 FOREIGN_KEY_VIOLATION
23505 UNIQUE_VIOLATION
23514 CHECK_VIOLATION
23P01 EXCLUSION_VIOLATION
Class 24 — Invalid Cursor State
24000 INVALID_CURSOR_STATE
Class 25 — Invalid Transaction State
25000 INVALID_TRANSACTION_STATE
25001 ACTIVE_SQL_TRANSACTION
25002 BRANCH_TRANSACTION_ALREADY_ACTIVE
25008 HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL
25003 INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION
25004 INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION
25005 NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION
25006 READ_ONLY_SQL_TRANSACTION
25007 SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED
25P01 NO_ACTIVE_SQL_TRANSACTION
25P02 IN_FAILED_SQL_TRANSACTION
Class 26 — Invalid SQL Statement Name
26000 INVALID_SQL_STATEMENT_NAME
Class 27 — Triggered Data Change Violation
27000 TRIGGERED_DATA_CHANGE_VIOLATION
Class 28 — Invalid Authorization Specification
28000 INVALID_AUTHORIZATION_SPECIFICATION
28P01 INVALID_PASSWORD
Class 2B — Dependent Privilege Descriptors Still Exist
2B000 DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST
2BP01 DEPENDENT_OBJECTS_STILL_EXIST
Class 2D — Invalid Transaction Termination
2D000 INVALID_TRANSACTION_TERMINATION
Class 2F — SQL Routine Exception
2F000 SQL_ROUTINE_EXCEPTION
2F005 FUNCTION_EXECUTED_NO_RETURN_STATEMENT
2F002 MODIFYING_SQL_DATA_NOT_PERMITTED
2F003 PROHIBITED_SQL_STATEMENT_ATTEMPTED
2F004 READING_SQL_DATA_NOT_PERMITTED
Class 34 — Invalid Cursor Name
34000 INVALID_CURSOR_NAME
Class 38 — External Routine Exception
38000 EXTERNAL_ROUTINE_EXCEPTION
38001 CONTAINING_SQL_NOT_PERMITTED
38002 MODIFYING_SQL_DATA_NOT_PERMITTED
38003 PROHIBITED_SQL_STATEMENT_ATTEMPTED
38004 READING_SQL_DATA_NOT_PERMITTED
Class 39 — External Routine Invocation Exception
39000 EXTERNAL_ROUTINE_INVOCATION_EXCEPTION
39001 INVALID_SQLSTATE_RETURNED
39004 NULL_VALUE_NOT_ALLOWED
39P01 TRIGGER_PROTOCOL_VIOLATED
39P02 SRF_PROTOCOL_VIOLATED
Class 3B — Savepoint Exception
3B000 SAVEPOINT_EXCEPTION
3B001 INVALID_SAVEPOINT_SPECIFICATION
Class 3D — Invalid Catalog Name
3D000 INVALID_CATALOG_NAME
Class 3F — Invalid Schema Name
3F000 INVALID_SCHEMA_NAME
Class 40 — Transaction Rollback
40000 TRANSACTION_ROLLBACK
40002 TRANSACTION_INTEGRITY_CONSTRAINT_VIOLATION
40001 SERIALIZATION_FAILURE
40003 STATEMENT_COMPLETION_UNKNOWN
40P01 DEADLOCK_DETECTED
Class 42 — Syntax Error or Access Rule Violation
42000 SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION
42601 SYNTAX_ERROR
42501 INSUFFICIENT_PRIVILEGE
42846 CANNOT_COERCE
42803 GROUPING_ERROR
42P20 WINDOWING_ERROR
42P19 INVALID_RECURSION
42830 INVALID_FOREIGN_KEY
42602 INVALID_NAME
42622 NAME_TOO_LONG
42939 RESERVED_NAME
42804 DATATYPE_MISMATCH
42P18 INDETERMINATE_DATATYPE
42P21 COLLATION_MISMATCH
42P22 INDETERMINATE_COLLATION
42809 WRONG_OBJECT_TYPE
42703 UNDEFINED_COLUMN
42883 UNDEFINED_FUNCTION
42P01 UNDEFINED_TABLE
42P02 UNDEFINED_PARAMETER
42704 UNDEFINED_OBJECT
42701 DUPLICATE_COLUMN
42P03 DUPLICATE_CURSOR
42P04 DUPLICATE_DATABASE
42723 DUPLICATE_FUNCTION
42P05 DUPLICATE_PREPARED_STATEMENT
42P06 DUPLICATE_SCHEMA
42P07 DUPLICATE_TABLE
42712 DUPLICATE_ALIAS
42710 DUPLICATE_OBJECT
42702 AMBIGUOUS_COLUMN
42725 AMBIGUOUS_FUNCTION
42P08 AMBIGUOUS_PARAMETER
42P09 AMBIGUOUS_ALIAS
42P10 INVALID_COLUMN_REFERENCE
42611 INVALID_COLUMN_DEFINITION
42P11 INVALID_CURSOR_DEFINITION
42P12 INVALID_DATABASE_DEFINITION
42P13 INVALID_FUNCTION_DEFINITION
42P14 INVALID_PREPARED_STATEMENT_DEFINITION
42P15 INVALID_SCHEMA_DEFINITION
42P16 INVALID_TABLE_DEFINITION
42P17 INVALID_OBJECT_DEFINITION
Class 44 — WITH CHECK OPTION Violation
44000 WITH_CHECK_OPTION_VIOLATION
Class 53 — Insufficient Resources
53000 INSUFFICIENT_RESOURCES
53100 DISK_FULL
53200 OUT_OF_MEMORY
53300 TOO_MANY_CONNECTIONS
53400 CONFIGURATION_LIMIT_EXCEEDED
Class 54 — Program Limit Exceeded
54000 PROGRAM_LIMIT_EXCEEDED
54001 STATEMENT_TOO_COMPLEX
54011 TOO_MANY_COLUMNS
54023 TOO_MANY_ARGUMENTS
Class 55 — Object Not In Prerequisite State
55000 OBJECT_NOT_IN_PREREQUISITE_STATE
55006 OBJECT_IN_USE
55P02 CANT_CHANGE_RUNTIME_PARAM
55P03 LOCK_NOT_AVAILABLE
Class 57 — Operator Intervention
57000 OPERATOR_INTERVENTION
57014 QUERY_CANCELED
57P01 ADMIN_SHUTDOWN
57P02 CRASH_SHUTDOWN
57P03 CANNOT_CONNECT_NOW
57P04 DATABASE_DROPPED
Class 58 — System Error (errors external to PostgreSQL itself)
58000 SYSTEM_ERROR
58030 IO_ERROR
58P01 UNDEFINED_FILE
58P02 DUPLICATE_FILE
Class F0 — Configuration File Error
F0000 CONFIG_FILE_ERROR
F0001 LOCK_FILE_EXISTS
Class HV — Foreign Data Wrapper Error (SQL/MED)
HV000 FDW_ERROR
HV005 FDW_COLUMN_NAME_NOT_FOUND
HV002 FDW_DYNAMIC_PARAMETER_VALUE_NEEDED
HV010 FDW_FUNCTION_SEQUENCE_ERROR
HV021 FDW_INCONSISTENT_DESCRIPTOR_INFORMATION
HV024 FDW_INVALID_ATTRIBUTE_VALUE
HV007 FDW_INVALID_COLUMN_NAME
HV008 FDW_INVALID_COLUMN_NUMBER
HV004 FDW_INVALID_DATA_TYPE
HV006 FDW_INVALID_DATA_TYPE_DESCRIPTORS
HV091 FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER
HV00B FDW_INVALID_HANDLE
HV00C FDW_INVALID_OPTION_INDEX
HV00D FDW_INVALID_OPTION_NAME
HV090 FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH
HV00A FDW_INVALID_STRING_FORMAT
HV009 FDW_INVALID_USE_OF_NULL_POINTER
HV014 FDW_TOO_MANY_HANDLES
HV001 FDW_OUT_OF_MEMORY
HV00P FDW_NO_SCHEMAS
HV00J FDW_OPTION_NAME_NOT_FOUND
HV00K FDW_REPLY_HANDLE
HV00Q FDW_SCHEMA_NOT_FOUND
HV00R FDW_TABLE_NOT_FOUND
HV00L FDW_UNABLE_TO_CREATE_EXECUTION
HV00M FDW_UNABLE_TO_CREATE_REPLY
HV00N FDW_UNABLE_TO_ESTABLISH_CONNECTION
Class P0 — PL/pgSQL Error
P0000 PLPGSQL_ERROR
P0001 RAISE_EXCEPTION
P0002 NO_DATA_FOUND
P0003 TOO_MANY_ROWS
Class XX — Internal Error
XX000 INTERNAL_ERROR
XX001 DATA_CORRUPTED
XX002 INDEX_CORRUPTED

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 4
This Week 8
This Month 55
Last Day 4
Last Week 21
Last Month 27
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |