From a632a3708016eebd943059f3d4c8969a4752728f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Wed, 21 Oct 2026 16:53:02 +0300 Subject: [PATCH] feat(domain):lab4 add Expected hint to UnsupportedMediaTypeError --- backend/internal/domain/errors.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 }