Files
hatchet/pkg/examples/workflows/non-retryable-error.go
Gabe Ruttner 8e80faf2d6 Fe overhaul docs (#1640)
* api changes

* doc changes

* move docs

* generated

* generate

* pkg

* backmerge main

* revert to main

* revert main

* race?

* remove go tests
2025-04-30 14:10:09 -07:00

32 lines
890 B
Go

package v1_workflows
import (
"errors"
"github.com/hatchet-dev/hatchet/pkg/client/create"
v1 "github.com/hatchet-dev/hatchet/pkg/v1"
"github.com/hatchet-dev/hatchet/pkg/v1/factory"
"github.com/hatchet-dev/hatchet/pkg/v1/workflow"
"github.com/hatchet-dev/hatchet/pkg/worker"
)
type NonRetryableInput struct{}
type NonRetryableResult struct{}
// NonRetryableError returns a workflow which throws a non-retryable error
func NonRetryableError(hatchet v1.HatchetClient) workflow.WorkflowDeclaration[NonRetryableInput, NonRetryableResult] {
// > Non Retryable Error
retries := factory.NewTask(
create.StandaloneTask{
Name: "non-retryable-task",
Retries: 3,
}, func(ctx worker.HatchetContext, input NonRetryableInput) (*NonRetryableResult, error) {
return nil, worker.NewNonRetryableError(errors.New("intentional failure"))
},
hatchet,
)
// !!
return retries
}