An error envelope gives clients stable places to find a code and details across failure types. The HTTP status gives the broad class; a body code distinguishes an actionable condition in the product. Validation failures can put field causes in details.
The demo maps validation, authorization, and server failures into one shape. Do not expose stacks or secrets in public messages, and document the meaning of stable codes.
When to use
Use it when frontends and SDKs need shared error handling across endpoints.