Commit 7c6fa5b3 authored by Mark Tyneway's avatar Mark Tyneway Committed by Liam Horne

l2geth: rollup client explicitly checks for >= 400 errors

parent cabb82c5
...@@ -24,6 +24,10 @@ const ( ...@@ -24,6 +24,10 @@ const (
// found. It applies to transactions, queue elements and batches // found. It applies to transactions, queue elements and batches
var errElementNotFound = errors.New("element not found") var errElementNotFound = errors.New("element not found")
// errHttpError represents the error case of when the remote server
// returns a 400 or greater error
var errHTTPError = errors.New("http error")
// Batch represents the data structure that is submitted with // Batch represents the data structure that is submitted with
// a series of transactions to layer one // a series of transactions to layer one
type Batch struct { type Batch struct {
...@@ -154,6 +158,15 @@ func NewClient(url string, chainID *big.Int) *Client { ...@@ -154,6 +158,15 @@ func NewClient(url string, chainID *big.Int) *Client {
client := resty.New() client := resty.New()
client.SetHostURL(url) client.SetHostURL(url)
client.SetHeader("User-Agent", "sequencer") client.SetHeader("User-Agent", "sequencer")
client.OnAfterResponse(func(c *resty.Client, r *resty.Response) error {
statusCode := r.StatusCode()
if statusCode >= 400 {
method := r.Request.Method
url := r.Request.URL
return fmt.Errorf("%d cannot %s %s: %w", statusCode, method, url, errHTTPError)
}
return nil
})
signer := types.NewEIP155Signer(chainID) signer := types.NewEIP155Signer(chainID)
return &Client{ return &Client{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment