-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy patherror_classifier.go
More file actions
55 lines (48 loc) · 1.65 KB
/
Copy patherror_classifier.go
File metadata and controls
55 lines (48 loc) · 1.65 KB
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
54
55
package schema
import "context"
// ErrorPhase identifies the resolver stage that produced an error.
type ErrorPhase int
const (
ErrorPhaseTableResolver ErrorPhase = iota
ErrorPhasePreResourceChunkResolver
ErrorPhasePreResourceResolver
ErrorPhaseColumnResolver
ErrorPhasePostResourceResolver
)
func (p ErrorPhase) String() string {
switch p {
case ErrorPhaseTableResolver:
return "table_resolver"
case ErrorPhasePreResourceChunkResolver:
return "pre_resource_chunk_resolver"
case ErrorPhasePreResourceResolver:
return "pre_resource_resolver"
case ErrorPhaseColumnResolver:
return "column_resolver"
case ErrorPhasePostResourceResolver:
return "post_resource_resolver"
default:
return "unknown"
}
}
// ErrorEvent describes the context in which a resolver error occurred.
type ErrorEvent struct {
Table *Table
Client ClientMeta
Phase ErrorPhase
// Column is set only when Phase == ErrorPhaseColumnResolver.
Column *Column
}
// ErrorClassifier reports whether a resolver error should be suppressed rather than
// raised. Suppressed errors are logged at debug level and are not counted in error
// metrics or emitted as a SyncError message. A nil ErrorClassifier raises every error.
// It is not consulted for primary key calculation or validation errors.
// The classifier may be invoked concurrently; implementations must be safe for concurrent use.
type ErrorClassifier func(ctx context.Context, err error, event ErrorEvent) bool
// Suppress is a nil-safe call: a nil ErrorClassifier returns false.
func (c ErrorClassifier) Suppress(ctx context.Context, err error, event ErrorEvent) bool {
if c == nil {
return false
}
return c(ctx, err, event)
}