small cleanups

This commit is contained in:
2022-12-23 20:27:21 +01:00
parent 56d9f977ae
commit cebb2ae2b6
9 changed files with 46 additions and 113 deletions

View File

@@ -1,12 +1,19 @@
package ginresp
type apiError struct {
Success bool `json:"success"`
Error int `json:"error"`
ErrorHighlight int `json:"errhighlight"`
Message string `json:"message"`
RawError *string `json:"errorObj,omitempty"`
Trace string `json:"traceObj,omitempty"`
Success bool `json:"success"`
Error int `json:"error"`
ErrorHighlight int `json:"errhighlight"`
Message string `json:"message"`
}
type extendedAPIError struct {
Success bool `json:"success"`
Error int `json:"error"`
ErrorHighlight int `json:"errhighlight"`
Message string `json:"message"`
RawError *string `json:"__error"`
Trace []string `json:"__trace"`
}
type compatAPIError struct {

View File

@@ -9,6 +9,7 @@ import (
"github.com/rs/zerolog/log"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"runtime/debug"
"strings"
)
type HTTPResponse interface {
@@ -110,13 +111,13 @@ func createApiError(g *gin.Context, ident string, status int, errorid apierr.API
if scn.Conf.ReturnRawErrors {
return &errorHTTPResponse{
statusCode: status,
data: apiError{
data: extendedAPIError{
Success: false,
Error: int(errorid),
ErrorHighlight: int(highlight),
Message: msg,
RawError: langext.Ptr(langext.Conditional(e == nil, "", fmt.Sprintf("%+v", e))),
Trace: string(debug.Stack()),
Trace: strings.Split(string(debug.Stack()), "\n"),
},
error: e,
}