feat(domain):lab4 add Expected hint to UnsupportedMediaTypeError

This commit is contained in:
Голиков Maximillian Антон
2026-10-21 16:53:02 +03:00
parent 7a0b02fc4e
commit a632a37080
+8 -3
View File
@@ -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 }