-
Notifications
You must be signed in to change notification settings - Fork 176
/
errors.go
53 lines (46 loc) · 1.23 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package fetcher
import (
"errors"
"fmt"
"github.com/onflow/flow-go/model/flow"
)
type ChunkDataPackValidationError struct {
originID flow.Identifier
chunkDataPackID flow.Identifier
chunkID flow.Identifier
collectionID flow.Identifier
resultID flow.Identifier
chunkIndex uint64
err error
}
func NewChunkDataPackValidationError(originID flow.Identifier,
resultID flow.Identifier,
chunkIndex uint64,
chunkDataPackID flow.Identifier,
chunkID flow.Identifier,
collectionID flow.Identifier,
err error) error {
return ChunkDataPackValidationError{
originID: originID,
chunkDataPackID: chunkDataPackID,
chunkID: chunkID,
collectionID: collectionID,
resultID: resultID,
chunkIndex: chunkIndex,
err: err,
}
}
func (c ChunkDataPackValidationError) Error() string {
return fmt.Sprintf(
"chunk data pack validation failed, originID: %x, resultID: %x, chunkIndex: %d, chunkDataPackID: %x, chunkID: %x, collectionID: %x, error: %v",
c.originID,
c.resultID,
c.chunkIndex,
c.chunkDataPackID,
c.chunkID,
c.collectionID,
c.err)
}
func IsChunkDataPackValidationError(err error) bool {
return errors.As(err, &ChunkDataPackValidationError{})
}