Jazuly
Jazuly

Reputation: 1414

How to exclude context from raise exception in postgresql

i want to throw error in function postgresql, but how if i want to exclude/remove the context from it errors?

what i try so far

RAISE 'messages error here (%) and here', NEW.request
      USING HINT = 'hint messages here';

i got return message error, hint and context..

SQLSTATE[P0001]: Raise exception: 7 ERROR: messages error here (var) and here\nHINT: hint messages here\nCONTEXT: PL/pgSQL function approval_list_fnc_status() line 23 at RAISE (SQL: update "table" set "field1" = value1, "field2" = value2 where "id" = 9528ac4b-e20f-4be4-b251-42f0e28df9a9)"

how if i want to exclude the context from error?

Upvotes: 2

Views: 1132

Answers (2)

eradman
eradman

Reputation: 2125

If you are using psql you can elide the context using

\set SHOW_CONTEXT never

Or if you also want to hide hints

\set VERBOSITY terse

Upvotes: 1

Laurenz Albe
Laurenz Albe

Reputation: 247235

The context information is always there, but all the attributes of an error message (detail, hint, context, ...) are separate, and it is up to your client code to use only the ones you are interested in.

Upvotes: 4

Related Questions