"How should I expose errors in my API?" there's an RFC for that
RFC 9457 : https://www.rfc-editor.org/rfc/rfc9457.html
This is mainly for backend people or frontenders that dabbles in creating APIs.
This RFC describes how errors should be reported by the servers in the context of REST APIs. This allows for a normalized way of exposing errors for both the human that needs to work with the API (you) and the code that needs to handle failed requests.
RFC 9457: Problem Details for HTTP APIs
This document defines a "problem detail" to carry machine-readable details of errors in HTTP response content to avoid the need to define new error response formats for HTTP APIs.
This document obsoletes RFC 7807.
0 Replies