-
Notifications
You must be signed in to change notification settings - Fork 2
/
dag_error.go
107 lines (86 loc) · 2.8 KB
/
dag_error.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) 2023 - 2024 vistart. All rights reserved.
// Use of this source code is governed by Apache-2.0 license
// that can be found in the LICENSE file.
package simple
import (
"fmt"
"reflect"
"strings"
)
// ErrChannelInterface indicates errors reported by the check channel.
type ErrChannelInterface interface {
error
}
// ErrChannelNotInitialized indicates that the channel map is not instantiated.
type ErrChannelNotInitialized struct {
ErrChannelInterface
}
func (e ErrChannelNotInitialized) Error() string {
return "channel map not initialized"
}
// ErrChannelNotExist indicates that the specified channel does not exist.
type ErrChannelNotExist struct {
ErrChannelInterface
name string
}
func (e ErrChannelNotExist) Error() string {
return fmt.Sprintf("channel[%s] not exist", e.name)
}
// ErrChannelInputNotSpecified indicates that the input channel is not specified.
type ErrChannelInputNotSpecified struct {
ErrChannelInterface
}
func (e ErrChannelInputNotSpecified) Error() string {
return "channel input not specified"
}
// ErrChannelOutputNotSpecified indicates that the output channel is not specified.
type ErrChannelOutputNotSpecified struct {
ErrChannelInterface
}
func (e ErrChannelOutputNotSpecified) Error() string {
return "channel output not specified"
}
// ErrChannelNameExisted indicates that the specified channel has existed.
type ErrChannelNameExisted struct {
ErrChannelInterface
name string
}
func (e ErrChannelNameExisted) Error() string {
return fmt.Sprintf("the channel[%s] has existed.", e.name)
}
// ErrRedundantChannels indicates that there are unused channelInputs.
type ErrRedundantChannels struct {
ErrChannelInterface
channels []string
}
func (e ErrRedundantChannels) Error() string {
return fmt.Sprintf("Redundant channelInputs: %v", strings.Join(e.channels, ", "))
}
// ErrTransitInterface represents the error reported by transit.
type ErrTransitInterface interface {
error
}
// ErrWorkerPanicked reports when the worker is panicked.
type ErrWorkerPanicked struct {
ErrTransitInterface
panic any
}
func (e ErrWorkerPanicked) Error() string {
return "worker panicked"
}
// ErrValueTypeMismatch defines that the data type output by the node is inconsistent with expectation.
type ErrValueTypeMismatch struct {
ErrTransitInterface
expect any
actual any
input string
}
func (e ErrValueTypeMismatch) Error() string {
return fmt.Sprintf("Expectation[%s] does not match actual[%s] received on channel[%s].",
reflect.TypeOf(e.expect), reflect.TypeOf(e.actual), e.input)
}
// NewErrValueTypeMismatch instantiates an error to indicate that the type of received data on in input channel
// does not match the actual.
func NewErrValueTypeMismatch(expect, actual any, input string) ErrValueTypeMismatch {
return ErrValueTypeMismatch{expect: expect, actual: actual, input: input}
}