refacotr: error handling in Listen method to use variable for noDataFoundError
This commit is contained in:
parent
601bfbbbde
commit
3129016364
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user