mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 02:31:19 +00:00
0452fd02e8
* attestations * post * tests * Revert "Auxiliary commit to revert individual files from afede4d949a7519902be2f1e0c485306c4ccdea7" This reverts commit 9de74879e0c41e43183da2fa7e63094cac030abe. * remove test * remove redundant return * Update beacon-chain/rpc/eth/beacon/handlers_pool.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * review * include index in broadcast log --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package shared
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// DecodeError represents an error resulting from trying to decode an HTTP request.
|
|
// It tracks the full field name for which decoding failed.
|
|
type DecodeError struct {
|
|
path []string
|
|
err error
|
|
}
|
|
|
|
// NewDecodeError wraps an error (either the initial decoding error or another DecodeError).
|
|
// The current field that failed decoding must be passed in.
|
|
func NewDecodeError(err error, field string) *DecodeError {
|
|
de, ok := err.(*DecodeError)
|
|
if ok {
|
|
return &DecodeError{path: append([]string{field}, de.path...), err: de.err}
|
|
}
|
|
return &DecodeError{path: []string{field}, err: err}
|
|
}
|
|
|
|
// Error returns the formatted error message which contains the full field name and the actual decoding error.
|
|
func (e *DecodeError) Error() string {
|
|
return fmt.Sprintf("could not decode %s: %s", strings.Join(e.path, "."), e.err.Error())
|
|
}
|
|
|
|
// IndexedVerificationFailureError wraps a collection of verification failures.
|
|
type IndexedVerificationFailureError struct {
|
|
Message string `json:"message"`
|
|
Code int `json:"code"`
|
|
Failures []*IndexedVerificationFailure `json:"failures"`
|
|
}
|
|
|
|
func (e *IndexedVerificationFailureError) StatusCode() int {
|
|
return e.Code
|
|
}
|
|
|
|
// IndexedVerificationFailure represents an issue when verifying a single indexed object e.g. an item in an array.
|
|
type IndexedVerificationFailure struct {
|
|
Index int `json:"index"`
|
|
Message string `json:"message"`
|
|
}
|