mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
ref: move httpapi.Reponse into codersdk (#2954)
This commit is contained in:
27
codersdk/error.go
Normal file
27
codersdk/error.go
Normal file
@ -0,0 +1,27 @@
|
||||
package codersdk
|
||||
|
||||
// Response represents a generic HTTP response.
|
||||
type Response struct {
|
||||
// Message is an actionable message that depicts actions the request took.
|
||||
// These messages should be fully formed sentences with proper punctuation.
|
||||
// Examples:
|
||||
// - "A user has been created."
|
||||
// - "Failed to create a user."
|
||||
Message string `json:"message"`
|
||||
// Detail is a debug message that provides further insight into why the
|
||||
// action failed. This information can be technical and a regular golang
|
||||
// err.Error() text.
|
||||
// - "database: too many open connections"
|
||||
// - "stat: too many open files"
|
||||
Detail string `json:"detail,omitempty"`
|
||||
// Validations are form field-specific friendly error messages. They will be
|
||||
// shown on a form field in the UI. These can also be used to add additional
|
||||
// context if there is a set of errors in the primary 'Message'.
|
||||
Validations []ValidationError `json:"validations,omitempty"`
|
||||
}
|
||||
|
||||
// ValidationError represents a scoped error to a user input.
|
||||
type ValidationError struct {
|
||||
Field string `json:"field" validate:"required"`
|
||||
Detail string `json:"detail" validate:"required"`
|
||||
}
|
Reference in New Issue
Block a user