summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hunteman <huntemanmt@gmail.com>2025-02-01 11:25:11 -0600
committerMichael Hunteman <huntemanmt@gmail.com>2025-02-01 11:25:11 -0600
commit23bcef02052c45089358d22d0645ceac858de3bb (patch)
treee91a69577a08e6c178abd19845f66866750d39fd
parenta2cc591ca13d351a20cc292dab29de2e1574d2c8 (diff)
Fix error message to return actual json
-rw-r--r--server/errors/models.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/server/errors/models.go b/server/errors/models.go
index 8f7d81c..2b90d21 100644
--- a/server/errors/models.go
+++ b/server/errors/models.go
@@ -2,7 +2,6 @@ package errors
import (
"encoding/json"
- "fmt"
)
type AppError struct {
@@ -11,9 +10,9 @@ type AppError struct {
}
func NewAppError(status int, msg string) *AppError {
- msgJson, err := json.Marshal(msg)
+ msgJson, err := json.Marshal(map[string]string{"message": msg})
if err != nil {
- msgJson = []byte(fmt.Sprintf(`{"message":"%s"}`, err.Error()))
+ msgJson, _ = json.Marshal(map[string]string{"message": err.Error()})
}
return &AppError{status, msgJson}
}