diff --git a/backend/internal/domain/errors.go b/backend/internal/domain/errors.go index df24988..0d196ac 100644 --- a/backend/internal/domain/errors.go +++ b/backend/internal/domain/errors.go @@ -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 }