fix(error): Refactor error handling to use errors.Is for more robust database error checking in Listen method.
This commit is contained in:
parent
7d4ce9f359
commit
40be98100e
@ -3,6 +3,7 @@ package plug
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
@ -51,9 +52,10 @@ func (p *Plug) Listen() error {
|
||||
|
||||
source, err = database.GetSourceByDomain(p.ctx, p.source.Domain)
|
||||
if err != nil {
|
||||
if err.Error() == otterError.NoDataFound {
|
||||
if errors.Is(err, &otterError.Database{Reason: otterError.NoDataFound}) {
|
||||
log.Printf("Initalizing source!")
|
||||
if source, err = database.CreateSource(p.ctx, p.source); err != nil {
|
||||
source, err = database.CreateSource(p.ctx, p.source)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user