use error.Is to handle wrapped errors

This commit is contained in:
Gani Georgiev 2023-12-04 16:21:57 +02:00
parent 0fb859c321
commit 41dcd9b4d4
2 changed files with 2 additions and 2 deletions

View File

@ -565,7 +565,7 @@ func (app *BaseApp) RefreshSettings() error {
encryptionKey := os.Getenv(app.EncryptionEnv()) encryptionKey := os.Getenv(app.EncryptionEnv())
storedSettings, err := app.Dao().FindSettings(encryptionKey) storedSettings, err := app.Dao().FindSettings(encryptionKey)
if err != nil && err != sql.ErrNoRows { if err != nil && !errors.Is(err, sql.ErrNoRows) {
return err return err
} }

View File

@ -20,7 +20,7 @@ func TestBaseAppRefreshSettings(t *testing.T) {
// check if the new settings are saved in the db // check if the new settings are saved in the db
app.ResetEventCalls() app.ResetEventCalls()
if err := app.RefreshSettings(); err != nil { if err := app.RefreshSettings(); err != nil {
t.Fatal("Failed to refresh the settings after delete") t.Fatalf("Failed to refresh the settings after delete: %v", err)
} }
testEventCalls(t, app, map[string]int{ testEventCalls(t, app, map[string]int{
"OnModelBeforeCreate": 1, "OnModelBeforeCreate": 1,