From 3b1483468cc0f8d954a36a9410ce5260e749a107 Mon Sep 17 00:00:00 2001 From: Reindert Vetter Date: Sat, 31 Oct 2020 23:05:35 +0100 Subject: [PATCH] lanvard/lanvard#73 ignore specific error --- app/report/errors.go | 15 ++++++++++++--- config/errors.go | 11 ++++++++--- src/controller/homepage.go | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/report/errors.go b/app/report/errors.go index fcdaaeb..8b005a4 100644 --- a/app/report/errors.go +++ b/app/report/errors.go @@ -7,9 +7,18 @@ import ( ) /** - * Below you will find a list of all user errors. By default these errors are not logged by config `config.Errors.NoLogging`. + * Below you will find a list of all user errors. By default these errors + * are not logged by config `config.Errors.NoLogging`. These errors are + * usually errors with http status 499 and lower. */ var UserError = errors.New("").Status(net.StatusBadRequest).Level(log_level.INFO) -var PageNotFound = UserError.Wrap("page not found").Status(net.StatusNotFound) +var ValidationError = UserError.Status(net.StatusNotFound) +var NotFoundError = UserError.Status(net.StatusNotFound) +var PageNotFoundError = UserError.Wrap("page not found") -var SystemError = errors.New("").Status(net.StatusInternalServerError) +/** + * This list contains errors that indicate that the system is not working + * properly. The message is not displayed to the user on a production environment, + * but will be logged (if MinLevel of the logger allows it). + */ +var SystemError = errors.New("").Status(net.StatusInternalServerError).Level(log_level.EMERGENCY) diff --git a/config/errors.go b/config/errors.go index cd1cb5f..5b2fe2f 100644 --- a/config/errors.go +++ b/config/errors.go @@ -1,11 +1,13 @@ package config -import "lanvard/app/report" +import ( + "github.com/lanvard/routing" + "lanvard/app/report" +) var Errors = struct { NoLogging []error }{ - /* |-------------------------------------------------------------------------- | No Logging @@ -15,6 +17,9 @@ var Errors = struct { | */ NoLogging: []error{ - report.UserError, + routing.MethodNotAllowedError, + routing.RouteNotFoundError, + report.ValidationError, + report.NotFoundError, }, } diff --git a/src/controller/homepage.go b/src/controller/homepage.go index cad06b9..a635160 100644 --- a/src/controller/homepage.go +++ b/src/controller/homepage.go @@ -7,5 +7,5 @@ import ( ) func Homepage(request inter.Request) inter.Response { - return outcome.Html(report.PageNotFound) + return outcome.Html(report.PageNotFoundError) }