-
Notifications
You must be signed in to change notification settings - Fork 175
/
errors.go
41 lines (34 loc) · 1.01 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
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
err error
}
func NewChunkDataPackValidationError(originID flow.Identifier,
chunkDataPackID flow.Identifier,
chunkID flow.Identifier,
collectionID flow.Identifier,
err error) error {
return ChunkDataPackValidationError{
originID: originID,
chunkDataPackID: chunkDataPackID,
chunkID: chunkID,
collectionID: collectionID,
err: err,
}
}
func (c ChunkDataPackValidationError) Error() string {
return fmt.Sprintf(
"chunk data pack validation failed, originID: %x, chunkDataPackID: %x, chunkID: %x, collectionID: %x, error: %v",
c.originID, c.chunkDataPackID, c.chunkID, c.collectionID, c.err)
}
func IsChunkDataPackValidationError(err error) bool {
return errors.As(err, &ChunkDataPackValidationError{})
}