NewError builds an envelope with an explicit machine-branchable code. Prefer this over the status-only helpers when the caller should be able to branch on something more specific than the HTTP status (e.g. "domain_not_verified" vs a bare 400).
(status int, code, message string)
| 64 | // to branch on something more specific than the HTTP status (e.g. |
| 65 | // "domain_not_verified" vs a bare 400). |
| 66 | func NewError(status int, code, message string) *ErrorEnvelope { |
| 67 | return &ErrorEnvelope{status: status, Err: ErrorBody{Code: code, Message: message}} |
| 68 | } |
| 69 | |
| 70 | // WithDetails attaches structured details and returns the envelope for |
| 71 | // fluent construction. |
no outgoing calls