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 {
|
type UnsupportedMediaTypeError struct {
|
||||||
MediaType string
|
MediaType string
|
||||||
|
Expected string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *UnsupportedMediaTypeError) Error() string {
|
func (e *UnsupportedMediaTypeError) Error() string {
|
||||||
if e.MediaType == "" {
|
expected := e.Expected
|
||||||
return "требуется Content-Type: application/json"
|
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) Unwrap() error { return ErrUnsupportedMediaType }
|
||||||
func (e *UnsupportedMediaTypeError) Code() ErrorCode { return CodeUnsupportedMediaType }
|
func (e *UnsupportedMediaTypeError) Code() ErrorCode { return CodeUnsupportedMediaType }
|
||||||
|
|||||||
Reference in New Issue
Block a user