Skip to content

errors

Structured PostgreSQL exceptions with JSON detail

errors · Structured PostgreSQL exceptions with JSON detail

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102139errorserrors0.47.0FUNCMITPLpgSQL
Relationships
Requiresplpgsql

Usage

Sources:

errors supplies the single errors.raise_error helper. It raises SQLSTATE P0001 with a code in MESSAGE and a JSON object containing code, context and class in DETAIL.

Core Workflow

CREATE EXTENSION "errors" CASCADE;
SELECT errors.raise_error('DEMO_ERROR', '{"field":"name"}'::jsonb, 'public');

Operational Boundaries

The example intentionally raises an exception. The class is application metadata, not access control: callers and logs still receive the supplied context. Keep secrets out of error payloads.

Version 0.47.0 is a SQL/PLpgSQL extension with no own shared library or preload. Install the matching dependency versions first: plpgsql. The control permits non-superuser installation but is not marked trusted; dependency, schema and role-grant privileges still apply. No current PostgreSQL-major matrix is declared.

Table reader