Skip to content

Commit d900321

Browse files
authored
Merge pull request #23 from axone-protocol/style/minor-improvements
style(engine): expose atom for panic_error term
2 parents b16f8f9 + 84f0213 commit d900321

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

engine/promise.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ var (
1010
falsePromise = &Promise{ok: false}
1111
)
1212

13+
var (
14+
AtomPanicError = NewAtom("panic_error")
15+
)
16+
1317
// PromiseFunc defines the type of a function that returns a promise.
1418
type PromiseFunc = func(context.Context) *Promise
1519

@@ -165,9 +169,9 @@ func panicError(r interface{}) error {
165169
case Exception:
166170
return r
167171
case error:
168-
return Exception{term: atomError.Apply(NewAtom("panic_error").Apply(NewAtom(r.Error())))}
172+
return Exception{term: atomError.Apply(AtomPanicError.Apply(NewAtom(r.Error())))}
169173
default:
170-
return Exception{term: atomError.Apply(NewAtom("panic_error").Apply(NewAtom(fmt.Sprintf("%v", r))))}
174+
return Exception{term: atomError.Apply(AtomPanicError.Apply(NewAtom(fmt.Sprintf("%v", r))))}
171175
}
172176
}
173177

@@ -217,12 +221,3 @@ func (s *promiseStack) recover(err error) error {
217221
// went through all the ancestor promises and still got the unhandled error.
218222
return err
219223
}
220-
221-
// PanicError is an error thrown once panic occurs during the execution of a promise.
222-
type PanicError struct {
223-
OriginErr error
224-
}
225-
226-
func (p PanicError) Error() string {
227-
return fmt.Sprintf("panic: %v", p.OriginErr)
228-
}

0 commit comments

Comments
 (0)