Skip to content

rm AppError; use isErrTerminal #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions pkg/loop/internal/net/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net

import (
"context"
"errors"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -109,31 +108,6 @@ func (c *clientConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, metho
return nil, context.Cause(ctx)
}

// AppError represents a custom application error that wraps another error.
type AppError struct {
Err error // Wrapped error
}

// Error implements the error interface for AppError.
func (e *AppError) Error() string {
if e.Err != nil {
return e.Err.Error()
}
return ""
}

// Unwrap allows access to the wrapped error.
func (e *AppError) Unwrap() error {
return e.Err
}

// NewAppError creates a new AppError instance.
func NewAppError(err error) *AppError {
return &AppError{
Err: err,
}
}

// refresh replaces c.cc with a new (different from orig) *grpc.ClientConn, and returns it as well.
// It will block until a new connection is successfully dialed, or return nil if the context expires.
func (c *clientConn) refresh(ctx context.Context, orig *grpc.ClientConn) (*grpc.ClientConn, error) {
Expand All @@ -155,9 +129,7 @@ func (c *clientConn) refresh(ctx context.Context, orig *grpc.ClientConn) (*grpc.
if err != nil {
c.Logger.Errorw("Client refresh attempt failed", "err", err)
c.CloseAll(deps...)

var appErr *AppError
if errors.As(err, &appErr) {
if !isErrTerminal(err) {
return false, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/loop/internal/relayerset/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (r *relayerClient) NewContractReader(_ context.Context, contractReaderConfi
cc := r.relayerSetClient.NewClientConn("ContractReader", func(ctx context.Context) (uint32, net.Resources, error) {
contractReaderID, err := r.relayerSetClient.NewContractReader(ctx, r.relayerID, contractReaderConfig)
if err != nil {
return 0, nil, net.NewAppError(err)
return 0, nil, fmt.Errorf("error getting NewContractReader from relayerSetServer: %w", err)
}

return contractReaderID, nil, nil
Expand Down
Loading