Skip to content

Commit 1b72464

Browse files

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

polycode/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var ErrTaskExecError = DefineError("polycode.client", 3, "task execution error")
99
var ErrUnknownError = DefineError("polycode.client", 4, "unknown error")
1010
var ErrPanic = DefineError("polycode.client", 5, "task in progress")
1111
var ErrTaskInProgress = &ErrPanic
12+
var ErrContextNotFound = DefineError("polycode.client", 6, "context not found")
1213

1314
type Error struct {
1415
Module string

workflowcontext/context.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package workflowcontext
2+
3+
import (
4+
"context"
5+
"github.com/CloudImpl-Inc/next-coder-sdk/polycode"
6+
)
7+
8+
func FromContext(ctx context.Context) (polycode.WorkflowContext, error) {
9+
value := ctx.Value("polycode.context")
10+
if value == nil {
11+
return polycode.WorkflowContext{}, polycode.ErrContextNotFound
12+
}
13+
14+
return value.(polycode.WorkflowContext), nil
15+
}

0 commit comments

Comments
 (0)