Skip to content

Commit 2250811

Browse files
authored
fixed double up errors and stack traces (#29)
1 parent 49eb9dd commit 2250811

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

cmd/rest-server/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ func main() {
8181
AllowOrigins: []string{"*"},
8282
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
8383
}))
84-
e.Use(p4Middleware.DebugDumpBody(log.DEBUG))
8584
e.HTTPErrorHandler = p4Middleware.ErrorHandler
8685
if cfg.Server.SwaggerEnabled {
8786
e.GET("/swagger/*", echoSwagger.WrapHandler)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/swaggo/echo-swagger v1.1.3
1616
github.com/swaggo/swag v1.7.3
1717
github.com/theflyingcodr/govalidator v0.0.2
18-
github.com/theflyingcodr/lathos v0.0.4
18+
github.com/theflyingcodr/lathos v0.0.5
1919
)
2020

2121
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ github.com/theflyingcodr/govalidator v0.0.2 h1:ahGtcJIwDVN9VdWRMbNPbiKnlikX4gC2P
328328
github.com/theflyingcodr/govalidator v0.0.2/go.mod h1:E6v0mkRcAVMTa7pC8VkUOtoE8WQ9zQ4/fOwrvtwhOM0=
329329
github.com/theflyingcodr/lathos v0.0.4 h1:YVHIsHLdCMrVyCqkZpBUQL2WekR1iuz8xpz101ZUWAk=
330330
github.com/theflyingcodr/lathos v0.0.4/go.mod h1:68tGFEbAqAzydWDb1KEJZPQY57l3hH32GXO11Hf1zGQ=
331+
github.com/theflyingcodr/lathos v0.0.5 h1:XmJvKBjzBdJWXsrtkkzl1XuWEzNMdJ1pKOozR91OrgY=
332+
github.com/theflyingcodr/lathos v0.0.5/go.mod h1:68tGFEbAqAzydWDb1KEJZPQY57l3hH32GXO11Hf1zGQ=
331333
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
332334
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
333335
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=

transports/http/middleware/debug_logger.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

transports/http/middleware/error_handler.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package middleware
22

33
import (
44
"errors"
5-
"fmt"
65
"net/http"
76

87
"github.com/labstack/echo/v4"
@@ -30,8 +29,15 @@ func ErrorHandler(err error, c echo.Context) {
3029

3130
// Internal error, log it to a system and return small detail
3231
if !lathos.IsClientError(err) {
32+
internalErr := errs.NewErrInternal(err, nil)
3333
log.Error(errs.NewErrInternal(err, nil))
34-
_ = c.String(http.StatusInternalServerError, fmt.Sprintf("%+v", err))
34+
35+
_ = c.JSON(http.StatusInternalServerError, p4.ClientError{
36+
ID: internalErr.ID(),
37+
Code: "500",
38+
Title: "Internal Server Error",
39+
Message: internalErr.Error(),
40+
})
3541
return
3642
}
3743
var clientErr lathos.ClientError

vendor/github.com/theflyingcodr/lathos/errs/internal.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ github.com/swaggo/swag
142142
# github.com/theflyingcodr/govalidator v0.0.2
143143
## explicit; go 1.15
144144
github.com/theflyingcodr/govalidator
145-
# github.com/theflyingcodr/lathos v0.0.4
145+
# github.com/theflyingcodr/lathos v0.0.5
146146
## explicit; go 1.17
147147
github.com/theflyingcodr/lathos
148148
github.com/theflyingcodr/lathos/errs

0 commit comments

Comments
 (0)