v0.0.207 renamed APIError to Error

This commit is contained in:
2023-07-25 10:47:00 +02:00
parent f826633e6e
commit fb847b03af
4 changed files with 12 additions and 12 deletions

View File

@@ -25,7 +25,7 @@ func Wrap(w *GinWrapper, fn WHandlerFunc) gin.HandlerFunc {
Str("trace", stackTrace).
Build()
wrap = APIError(g, err)
wrap = Error(g, err)
}
if g.Writer.Written() {

View File

@@ -52,7 +52,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
WithType(exerr.TypeBindFailURI).
Str("struct_type", fmt.Sprintf("%T", pctx.uri)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
}
@@ -62,7 +62,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
WithType(exerr.TypeBindFailQuery).
Str("struct_type", fmt.Sprintf("%T", pctx.query)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
}
@@ -73,13 +73,13 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
WithType(exerr.TypeBindFailJSON).
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
} else {
err := exerr.New(exerr.TypeBindFailJSON, "missing JSON body").
Str("struct_type", fmt.Sprintf("%T", pctx.body)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
}
@@ -90,13 +90,13 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
WithType(exerr.TypeBindFailFormData).
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
} else {
err := exerr.New(exerr.TypeBindFailFormData, "missing form body").
Str("struct_type", fmt.Sprintf("%T", pctx.form)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
}
@@ -106,7 +106,7 @@ func (pctx PreContext) Start() (*AppContext, *gin.Context, *HTTPResponse) {
WithType(exerr.TypeBindFailHeader).
Str("struct_type", fmt.Sprintf("%T", pctx.query)).
Build()
return nil, nil, langext.Ptr(APIError(pctx.ginCtx, err))
return nil, nil, langext.Ptr(Error(pctx.ginCtx, err))
}
}

View File

@@ -170,12 +170,12 @@ func Redirect(sc int, newURL string) HTTPResponse {
return &redirectHTTPResponse{statusCode: sc, url: newURL}
}
func APIError(g *gin.Context, e error) HTTPResponse {
func Error(g *gin.Context, e error) HTTPResponse {
return &jsonAPIErrResponse{
err: exerr.FromError(e),
}
}
func NotImplemented(g *gin.Context) HTTPResponse {
return APIError(g, exerr.New(exerr.TypeNotImplemented, "").Build())
return Error(g, exerr.New(exerr.TypeNotImplemented, "").Build())
}