@@ -297,37 +297,37 @@ import (
297
297
// ReportError handles an error, changes status code based on the error,
298
298
// and reports to an external service if necessary
299
299
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 {
302
302
// As it's a "raw" error, `StackTrace` field left unset.
303
303
// And it should be always reported
304
- appErr = &fail.Error {
304
+ failErr = &fail.Error {
305
305
Err: err,
306
306
}
307
307
}
308
308
309
- convertAppError (appErr )
309
+ convertFailError (failErr )
310
310
311
311
// 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 )
314
314
}
315
315
316
316
// Expose an error message in the header
317
- if msg := appErr .LastMessage (); msg != " " {
317
+ if msg := failErr .LastMessage (); msg != " " {
318
318
c.Header (" X-App-Error" , msg)
319
319
}
320
320
321
321
// Set status code accordingly
322
- switch code := appErr .Code .(type ) {
322
+ switch code := failErr .Code .(type ) {
323
323
case int :
324
324
c.Status (code)
325
325
default :
326
326
c.Status (http.StatusInternalServerError )
327
327
}
328
328
}
329
329
330
- func convertAppError (err *fail .Error ) {
330
+ func convertFailError (err *fail .Error ) {
331
331
// If the error is from ORM and it says "no record found,"
332
332
// override status code to 404
333
333
if err.Err == gorm.ErrRecordNotFound {
@@ -336,7 +336,7 @@ func convertAppError(err *fail.Error) {
336
336
}
337
337
}
338
338
339
- func uploadAppError (c *gin .Context , err *fail .Error ) {
339
+ func uploadFailError (c *gin .Context , err *fail .Error ) {
340
340
// By using readbody, you can retrive an original request body
341
341
// even when c.Request.Body had been read
342
342
body := readbody.Get (c)
0 commit comments