Add APIErrorWrapper so that underlying errors can be logged (#1246)

This commit is contained in:
Owen Strain
2018-09-28 17:26:54 -07:00
committed by GitHub
parent 0dd24932f2
commit 21f77f837e
4 changed files with 48 additions and 10 deletions

View File

@@ -27,6 +27,9 @@ func handleErrorResponse(c *gin.Context, err error) {
// HandleErrorResponse used to handle response errors in the same way.
func HandleErrorResponse(ctx context.Context, w http.ResponseWriter, err error) {
log := common.Logger(ctx)
if w, ok := err.(models.APIErrorWrapper); ok {
log = log.WithField("root_error", w.RootError())
}
if ctx.Err() == context.Canceled {
log.Info("client context cancelled")