summaryrefslogtreecommitdiff
path: root/internal/api/util/errorhandling.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/util/errorhandling.go')
-rw-r--r--internal/api/util/errorhandling.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/api/util/errorhandling.go b/internal/api/util/errorhandling.go
index 4fa544ffd..8bb251040 100644
--- a/internal/api/util/errorhandling.go
+++ b/internal/api/util/errorhandling.go
@@ -55,7 +55,9 @@ func NotFoundHandler(c *gin.Context, instanceGet func(ctx context.Context) (*api
"requestID": gtscontext.RequestID(ctx),
})
default:
- c.JSON(http.StatusNotFound, gin.H{"error": errWithCode.Safe()})
+ JSON(c, http.StatusNotFound, map[string]string{
+ "error": errWithCode.Safe(),
+ })
}
}
@@ -78,7 +80,9 @@ func genericErrorHandler(c *gin.Context, instanceGet func(ctx context.Context) (
"requestID": gtscontext.RequestID(ctx),
})
default:
- c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})
+ JSON(c, errWithCode.Code(), map[string]string{
+ "error": errWithCode.Safe(),
+ })
}
}
@@ -102,7 +106,7 @@ func ErrorHandler(
c *gin.Context,
errWithCode gtserror.WithCode,
instanceGet func(ctx context.Context) (*apimodel.InstanceV1, gtserror.WithCode),
- offers ...MIME,
+ offers ...string,
) {
if ctxErr := c.Request.Context().Err(); ctxErr != nil {
// Context error means either client has left already,
@@ -175,7 +179,7 @@ func OAuthErrorHandler(c *gin.Context, errWithCode gtserror.WithCode) {
l.Debug("handling OAuth error")
}
- c.JSON(statusCode, gin.H{
+ JSON(c, statusCode, map[string]string{
"error": errWithCode.Error(),
"error_description": errWithCode.Safe(),
})