feat(domain):lab4 add Expected hint to UnsupportedMediaTypeError
This commit is contained in:
@@ -145,13 +145,18 @@ func (e *UnauthorizedError) Code() ErrorCode { return CodeUnauthorized }
|
||||
// увидит неверную подсказку.
|
||||
type UnsupportedMediaTypeError struct {
|
||||
MediaType string
|
||||
Expected string
|
||||
}
|
||||
|
||||
func (e *UnsupportedMediaTypeError) Error() string {
|
||||
if e.MediaType == "" {
|
||||
return "требуется Content-Type: application/json"
|
||||
expected := e.Expected
|
||||
if expected == "" {
|
||||
expected = "application/json"
|
||||
}
|
||||
return fmt.Sprintf("неподдерживаемый Content-Type %q; требуется application/json", e.MediaType)
|
||||
if e.MediaType == "" {
|
||||
return "требуется Content-Type: " + expected
|
||||
}
|
||||
return fmt.Sprintf("неподдерживаемый Content-Type %q; требуется %s", e.MediaType, expected)
|
||||
}
|
||||
func (e *UnsupportedMediaTypeError) Unwrap() error { return ErrUnsupportedMediaType }
|
||||
func (e *UnsupportedMediaTypeError) Code() ErrorCode { return CodeUnsupportedMediaType }
|
||||
|
||||
Reference in New Issue
Block a user