From 20b426935837a70f7b6144fa7eea3180ae0d4920 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 21 Oct 2025 15:47:39 +0300 Subject: [PATCH] add a custom error struct that carries both fields from the API error --- handlers/application/menuhandler.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 4c7b4ec..f2e7fc1 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -28,6 +28,19 @@ var ( translationDir = path.Join(scriptDir, "locale") ) +// custom error struct that carries both fields from the API error +type APIError struct { + Code string + Description string +} + +func (e *APIError) Error() string { + if e.Code != "" { + return fmt.Sprintf("[%s] %s", e.Code, e.Description) + } + return e.Description +} + // TODO: this is only in use in testing, should be moved to test domain and/or replaced by asm.FlagParser // FlagManager handles centralized flag management type FlagManager struct {