pg_error_parser
A micro-module to make sense of error messages in postgresql. Works well with the pg
module.
npm install pg_error_parser
Usage
format(error)
Takes an error object and adds more information to it. Useful when logging error objects and needing to see some normalized data.
Error lookups are based on the sqlState
key of the error object.
Format will add the following keys to the error object:
code_name
Values such as not_null_violation
, unique_violation
, or invalid_sql_statement_name
.
code_level
The severity of the error, either info
, warning
, or error
.
code_group_name
A human readable name for this type of error like Integrity Constraint Violation
, Invalid Transaction State
, or Data Exception
.
var pg = ;var pgep = ;var client = ; client;
getLevel(code)
Returns the error level of a given code.
// error // warn // info
getCodeName(code)
Returns the code name of a given code.
// unique_violation // deprecated_feature // successful_completion
getGroupName(code)
Returns the human readable name for and error if this type.
// Integrity Constraint Violation // Warning // Successful Completion
License
MIT