github.com/koko1123/flow-go-1@v0.29.6/fvm/derived/error.go (about)

     1  package derived
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type RetryableError interface {
     8  	error
     9  	IsRetryable() bool
    10  }
    11  
    12  type retryableError struct {
    13  	error
    14  
    15  	isRetryable bool
    16  }
    17  
    18  func newRetryableError(msg string, vals ...interface{}) RetryableError {
    19  	return retryableError{
    20  		error:       fmt.Errorf(msg, vals...),
    21  		isRetryable: true,
    22  	}
    23  }
    24  
    25  func newNotRetryableError(msg string, vals ...interface{}) RetryableError {
    26  	return retryableError{
    27  		error:       fmt.Errorf(msg, vals...),
    28  		isRetryable: false,
    29  	}
    30  }
    31  
    32  func (err retryableError) IsRetryable() bool {
    33  	return err.isRetryable
    34  }