The field fmterrtbl
of pg_exttable contains the oid of the error table for any external table. So the query to find the error table for all external tables in the database is:
SELECT
external_namespace.nspname AS external_schema, external_class.relname AS external_table,
error_namespace.nspname AS error_schema, error_class.relname AS error_table
FROM pg_exttable AS external_tables
INNER JOIN pg_class AS external_class ON external_class.oid = external_tables.reloid
INNER JOIN pg_namespace AS external_namespace ON external_namespace.oid = external_class.relnamespace
LEFT JOIN (
pg_class AS error_class
INNER JOIN pg_namespace AS error_namespace ON error_namespace.oid = error_class.relnamespace
) ON error_class.oid = external_tables.fmterrtbl
the error_schema and error_table fields will be NULL for external tables with no error tables.