refacotr: error handling in Listen method to use variable for noDataFoundError

This commit is contained in:
SoXX 2024-08-24 23:52:36 +02:00
parent 601bfbbbde
commit 3129016364

View File

@ -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 {