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:
Cian Johnston
2022-07-27 22:20:02 +01:00
committed by GitHub
parent 36ffdce065
commit 27ea415b6c
5 changed files with 34 additions and 27 deletions

View File

@ -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 {