psql shows a short error by default. When you need more, you don’t have to change a setting and run the failing query again.
appdb=# INSERT INTO orders (customer_id) VALUES (999);
ERROR: insert or update on table "orders" violates foreign key constraint "orders_customer_id_fkey"
appdb=# \errverbose
\errverbose prints the most recent server error again at full verbosity. You get the SQLSTATE code, such as 23503, the DETAIL and HINT lines, the context, and the place in the PostgreSQL source that raised it. The SQLSTATE is what to search for and what app code should check, because the message text can change between versions and languages.
The context part helps most with errors inside functions and triggers. It shows which function and which line was running, which the short message leaves out.
To get this level of detail for every error, run \set VERBOSITY verbose, but that makes normal work noisy. I prefer to ask afterwards. It only repeats the last error from the server, so a psql-side problem such as a bad meta-command is not included. And the source file and line numbers point into the server’s C code, which helps when you report a bug and not much otherwise.
Further reading: psql (\errverbose), PostgreSQL error codes