Skip to content
Written with Claude

ERROR_CODE_POLICY

Also known as

error_code_policy, error_code (with or without @ prefix)

Associate an error handling policy with the endpoint.

Syntax

code
@error_code_policy <policy-name>
@error_code <policy-name>

Examples

Named Policy

sql
sql
comment on function risky_operation() is
'HTTP POST
@error_code_policy strict_errors';

Short Form

sql
sql
comment on function api_endpoint() is
'HTTP GET
@error_code default_policy';

Behavior

  • References an error policy defined in the ErrorCodePolicies configuration
  • Controls how PostgreSQL errors are mapped to HTTP status codes
  • Defines error response format

See Also

Comments