-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
74 lines (58 loc) · 1.11 KB
/
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
package loong
import (
"context"
"github.com/it512/loong/bpmn"
)
type SystemError struct {
error
}
type BizErr struct {
ErrorCode string
}
func NewBizErr(errCode string) *BizErr {
return &BizErr{ErrorCode: errCode}
}
func (e BizErr) Error() string {
return e.ErrorCode
}
func w(e error, sid string, v Variable) error {
if be, ok := e.(*BizErr); ok {
return &actErrOp{
Variable: v,
SourceID: sid,
BizErr: be,
}
}
return e
}
type boundaryErrorEventActivity interface {
Activity
Match() bool
}
type actErrOp struct {
Variable
bpmn.TBoundaryEvent
SourceID string
*BizErr
UnimplementedActivity
}
func (a *actErrOp) Match() bool {
te, ok := a.Template.FindErrorByCode(a.ErrorCode)
if !ok {
return false
}
for _, be := range a.Template.Definitions.Process.BoundaryEvent {
if be.AttachedToRef == a.SourceID {
if ed, ok := be.GetErrorEventDefinition2(); ok {
if ed.ErrorRef == te.GetId() {
a.TBoundaryEvent = be
return true
}
}
}
}
return false
}
func (a *actErrOp) Emit(ctx context.Context, emt Emitter) error {
return emt.Emit(fromOuter(ctx, a.Variable, a))
}