From 312901636474657e4ff0f5927e387560918d7723 Mon Sep 17 00:00:00 2001 From: SoXX Date: Sat, 24 Aug 2024 23:52:36 +0200 Subject: [PATCH] refacotr: error handling in Listen method to use variable for noDataFoundError --- pkg/plug/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/plug/server.go b/pkg/plug/server.go index c2b75cc..ccdfa4e 100644 --- a/pkg/plug/server.go +++ b/pkg/plug/server.go @@ -50,9 +50,11 @@ func (p *Plug) Listen() error { var err error var source models.Source + noDataFoundError := otterError.Database{Reason: otterError.NoDataFound} + source, err = database.GetSourceByDomain(p.ctx, p.source.Domain) if err != nil { - if errors.Is(err, otterError.Database{Reason: otterError.NoDataFound}) { + if errors.Is(err, noDataFoundError) { log.Printf("Initalizing source!") source, err = database.CreateSource(p.ctx, p.source) if err != nil {