Skip to content

Commit

Permalink
Add NewWithContext function to process.go for creating processes with…
Browse files Browse the repository at this point in the history
… context support; improves error handling during process initialization.
  • Loading branch information
trheyi committed Dec 12, 2024
1 parent e2b531d commit b6515a6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ func New(name string, args ...interface{}) *Process {
return process
}

// NewWithContext make a new process with context
func NewWithContext(ctx context.Context, name string, args ...interface{}) *Process {
process, err := Of(name, args...)
if err != nil {
exception.New("%s", 500, err.Error()).Throw()
}
return process
}

// Of make a new process and return error
func Of(name string, args ...interface{}) (*Process, error) {
process := &Process{Name: name, Args: args, Global: map[string]interface{}{}}
Expand Down

0 comments on commit b6515a6

Please sign in to comment.