mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Use eris for error management
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/rotisserie/eris"
|
||||
)
|
||||
|
||||
var colorReset, colorGray, colorYellow, colorBlue, colorRed, colorMagenta, colorBlack, colorWhite *color.Color
|
||||
@ -98,7 +99,7 @@ func (l *Logger) Configure(c *Config) error {
|
||||
defer l.mux.Unlock()
|
||||
|
||||
if c == nil {
|
||||
return fmt.Errorf("a non nil Config is mandatory")
|
||||
return eris.Errorf("a non nil Config is mandatory")
|
||||
}
|
||||
|
||||
if err := c.LogThreshold.validate(); err != nil {
|
||||
@ -125,7 +126,7 @@ func (l Level) validate() error {
|
||||
case DebugLevel, InfoLevel, WarnLevel, ErrorLevel:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid \"Level\" %d", l)
|
||||
return eris.Errorf("invalid \"Level\" %d", l)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,13 @@ package logger
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/rotisserie/eris"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -34,7 +33,7 @@ func TestThreshold(t *testing.T) {
|
||||
Info("this should display")
|
||||
assert.NotEmpty(t, buf.String())
|
||||
|
||||
Error("ErrorClass", errors.New("this should display"))
|
||||
Error("ErrorClass", eris.New("this should display"))
|
||||
assert.NotEmpty(t, buf.String())
|
||||
}
|
||||
|
||||
@ -97,7 +96,7 @@ func TestError(t *testing.T) {
|
||||
LogThreshold: ErrorLevel,
|
||||
}))
|
||||
|
||||
Error("TestErrorClass", fmt.Errorf("this is a %s error", "test"))
|
||||
Error("TestErrorClass", eris.Errorf("this is a %s error", "test"))
|
||||
assert.Contains(t, buf.String(), "ERROR")
|
||||
assert.Contains(t, buf.String(), "this is a test error")
|
||||
}
|
||||
|
Reference in New Issue
Block a user