all repos — searchix @ 3dfbd8dd7212f74622ba4892efb34bf3487da09b

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: switch from errors to fault

Alan Pearce
commit

3dfbd8dd7212f74622ba4892efb34bf3487da09b

parent

e72b060271452e25bbcb2799fc19996ff73689fd

1 file changed, 10 insertions(+), 10 deletions(-)

changed files
M internal/server/server.gointernal/server/server.go
@@ -12,7 +12,8 @@ "alin.ovh/searchix/internal/index"
"alin.ovh/searchix/internal/manpages" "alin.ovh/x/log" - "gitlab.com/tozd/go/errors" + "github.com/Southclaws/fault" + "github.com/Southclaws/fault/fmsg" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" )
@@ -36,7 +37,7 @@ conf *config.Config,
options *Options, log *log.Logger, liveReload bool, -) (*Server, errors.E) { +) (*Server, error) { mux, err := NewMux(conf, options, log, liveReload) if err != nil { return nil, err
@@ -57,16 +58,15 @@ },
}, nil } -func (s *Server) Start() errors.E { +func (s *Server) Start() error { listenAddress := net.JoinHostPort(s.cfg.Web.ListenAddress, strconv.Itoa(s.cfg.Web.Port)) l, err := net.Listen("tcp", listenAddress) if err != nil { - return errors.WithMessagef( - err, - "could not listen on address %s and port %d", - s.cfg.Web.ListenAddress, - s.cfg.Web.Port, - ) + return fault.Wrap( + err, fmsg.Withf("could not listen on address %s and port %d", + s.cfg.Web.ListenAddress, + s.cfg.Web.Port, + )) } s.listener = l
@@ -79,7 +79,7 @@ )
} if err := s.server.Serve(l); err != nil && err != http.ErrServerClosed { - return errors.WithMessage(err, "could not start server") + return fault.Wrap(err, fmsg.With("could not start server")) } return nil