Skip to content

Commit

Permalink
Support wrapped err check using errors.Is (#8)
Browse files Browse the repository at this point in the history
* chore: use errors.Is to support wrapped errors

* ci: add go 1.21.x, 1.22.x to test matrix
  • Loading branch information
ajatprabha authored Jul 16, 2024
1 parent 10f68fb commit 1f8a255
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go-version: [1.19.x, 1.20.x, 1.21.x, 1.22.x]
steps:
- name: Install Go
uses: actions/setup-go@v4
Expand Down
3 changes: 2 additions & 1 deletion component/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package component

import (
"context"
"errors"
"net/http"

"github.com/gojekfarm/xrun"
Expand All @@ -28,7 +29,7 @@ func HTTPServer(opts HTTPServerOptions) xrun.ComponentFunc {
ps()
}

if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
errCh <- err
}
}()
Expand Down
3 changes: 2 additions & 1 deletion component/x/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grpc

import (
"context"
"errors"
"net"

"google.golang.org/grpc"
Expand Down Expand Up @@ -39,7 +40,7 @@ func Server(opts Options) xrun.ComponentFunc {
ps()
}

if err := srv.Serve(l); err != nil && err != grpc.ErrServerStopped {
if err := srv.Serve(l); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
errCh <- err
}
}(errCh)
Expand Down

0 comments on commit 1f8a255

Please sign in to comment.