Skip to content

Commit 685e8c9

Browse files
authored
Merge pull request #21 from srvc/creasty/v4.0.0
v4.0.0
2 parents 07e504e + 1fa73da commit 685e8c9

File tree

4 files changed

+132
-146
lines changed

4 files changed

+132
-146
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -297,37 +297,37 @@ import (
297297
// ReportError handles an error, changes status code based on the error,
298298
// and reports to an external service if necessary
299299
func ReportError(c *gin.Context, err error) {
300-
appErr := fail.Unwrap(err)
301-
if appErr == nil {
300+
failErr := fail.Unwrap(err)
301+
if failErr == nil {
302302
// As it's a "raw" error, `StackTrace` field left unset.
303303
// And it should be always reported
304-
appErr = &fail.Error{
304+
failErr = &fail.Error{
305305
Err: err,
306306
}
307307
}
308308

309-
convertAppError(appErr)
309+
convertFailError(failErr)
310310

311311
// Send the error to an external service
312-
if !appErr.Ignorable {
313-
go uploadAppError(c.Copy(), appErr)
312+
if !failErr.Ignorable {
313+
go uploadFailError(c.Copy(), failErr)
314314
}
315315

316316
// Expose an error message in the header
317-
if msg := appErr.LastMessage(); msg != "" {
317+
if msg := failErr.LastMessage(); msg != "" {
318318
c.Header("X-App-Error", msg)
319319
}
320320

321321
// Set status code accordingly
322-
switch code := appErr.Code.(type) {
322+
switch code := failErr.Code.(type) {
323323
case int:
324324
c.Status(code)
325325
default:
326326
c.Status(http.StatusInternalServerError)
327327
}
328328
}
329329

330-
func convertAppError(err *fail.Error) {
330+
func convertFailError(err *fail.Error) {
331331
// If the error is from ORM and it says "no record found,"
332332
// override status code to 404
333333
if err.Err == gorm.ErrRecordNotFound {
@@ -336,7 +336,7 @@ func convertAppError(err *fail.Error) {
336336
}
337337
}
338338

339-
func uploadAppError(c *gin.Context, err *fail.Error) {
339+
func uploadFailError(c *gin.Context, err *fail.Error) {
340340
// By using readbody, you can retrive an original request body
341341
// even when c.Request.Body had been read
342342
body := readbody.Get(c)

error.go

-6
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ func (e *Error) LastMessage() string {
7474
return e.Messages[0]
7575
}
7676

77-
// FullMessage is marked as deprecated in favor of `Error`.
78-
// This method will be removed in the next major release.
79-
func (e *Error) FullMessage() string {
80-
return e.Error()
81-
}
82-
8377
// Wrap returns an error annotated with a stack trace from the point it was called,
8478
// and with the specified annotators.
8579
// It returns nil if err is nil.

0 commit comments

Comments
 (0)