Skip to content

Blame where blame is

Choose a tag to compare

@bw19 bw19 released this 11 Jul 15:49
· 2 commits to main since this release

This release makes dv8's errors self-attributing. Errors are now created with the microbus-io/errors package, dv8's first dependency, and carry an HTTP status code and a stack trace. A violation of the input data, such as a failed directive, a key-fold collision, or a rejection by a custom Validate method, is stamped 400 Bad Request, while a malformed directive, which is a bug in the struct tags rather than in the input, carries 500 Internal Server Error and continues to wrap dv8.ErrDirective for errors.Is matching. A custom Validate method may choose its own attribution by returning an error with any non-500 status code (e.g. errors.New("forbidden", http.StatusForbidden)), which dv8 respects; a plain error, or one carrying the default 500, is treated as a data rejection and stamped 400. Callers that route errors to HTTP responses can therefore propagate them as-is with errors.StatusCode(err) reading the code back, instead of branching on the error kind themselves. The status survives dv8's own field-path prefixing through nested structs, slices, and maps.