refactor: use SetError in exception.Builder where errors are available

Update multiple services and middlewares to pass the original error to exception.Builder before building the error code.

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
2026-01-21 14:42:52 +08:00
parent 14f50ecdb2
commit a60a796345
13 changed files with 46 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ func Exchange(c *gin.Context) {
SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
SetError(err).
Build()
utils.HttpResponse(c, 400, errorCode)
return
@@ -56,6 +57,7 @@ func Exchange(c *gin.Context) {
SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
SetError(err).
Build()
utils.HttpResponse(c, 500, errorCode)
return
@@ -70,6 +72,7 @@ func Exchange(c *gin.Context) {
SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeGetUserIdFailed).
SetError(err).
Build()
utils.HttpResponse(c, 500, errorCode)
return
@@ -83,6 +86,7 @@ func Exchange(c *gin.Context) {
SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeCodeGenFailed).
SetError(err).
Build()
utils.HttpResponse(c, 500, errorCode)
return
@@ -96,6 +100,7 @@ func Exchange(c *gin.Context) {
SetEndpoint(exception.EndpointAuthServiceExchange).
SetType(exception.TypeSpecific).
SetOriginal(exception.AuthExchangeInvalidRedirectUri).
SetError(err).
Build()
utils.HttpResponse(c, 400, errorCode)
return