mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: remove string TTL from workspace error responses (#3257)
- Rewrites some error messages to better integrate with the frontend (ttl_ms -> time until shutdown) - Makes codersdk.ValidationError implement the error interface - Only return validations if the error was a validation error, return detail otherwise (e.g. database error)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package codersdk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
@ -32,6 +33,12 @@ type ValidationError struct {
|
||||
Detail string `json:"detail" validate:"required"`
|
||||
}
|
||||
|
||||
func (e ValidationError) Error() string {
|
||||
return fmt.Sprintf("field: %s detail: %s", e.Field, e.Detail)
|
||||
}
|
||||
|
||||
var _ error = (*ValidationError)(nil)
|
||||
|
||||
// IsConnectionErr is a convenience function for checking if the source of an
|
||||
// error is due to a 'connection refused', 'no such host', etc.
|
||||
func IsConnectionErr(err error) bool {
|
||||
|
Reference in New Issue
Block a user