IsPgErrorWithCode
Checks if a given error is a PostgreSQL error with a specific error code.
def IsPgErrorWithCode(
err: error,
code: string
) - > bool
Checks if a given error is a PostgreSQL error with a specific error code. This function is useful for handling database-specific errors and implementing custom error logic based on PostgreSQL error codes.
Parameters
| Name | Type | Description |
|---|---|---|
| err | error | The error object to check. This should be an error that might potentially be a PostgreSQL error. |
| code | string | The PostgreSQL error code to compare against. This code is typically a 5-character SQLSTATE code. |
Returns
| Type | Description |
|---|---|
bool | True if the error is a PostgreSQL error and its code matches the provided code, otherwise False. |