Files
tasks/common/softassert/serviceerror.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

57 lines
1.9 KiB
Go

package softassert
import (
"fmt"
"go.temporal.io/api/serviceerror"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/log/tag"
)
const (
// using a unique tag name to avoid potential conflicts with other tags
errorDetailsTagName = "softassert-error-details"
)
// UnexpectedInternalErr creates a serviceerror.Internal from a static message and error details.
// The error message follows the format "<staticMessage>: <optionalErr>", if optionalErr is not nil.
//
// It also logs `staticMessage` using softassert.Fail.
// `optionalErr` is added as a tag with key "softassert-error-details".
func UnexpectedInternalErr(logger log.Logger, staticMessage string, optionalErr error, tags ...tag.Tag) error {
// (1) trigger softassert
combinedTags := tags
if optionalErr != nil {
combinedTags = append([]tag.Tag{tag.NewErrorTag(errorDetailsTagName, optionalErr)}, tags...)
}
Fail(logger, staticMessage, combinedTags...)
// (2) return serviceerror
message := staticMessage
if optionalErr != nil {
message = fmt.Sprintf("%s: %s", staticMessage, optionalErr)
}
return serviceerror.NewInternal(message)
}
// UnexpectedDataLoss creates a serviceerror.DataLoss from a static message and optional error.
// The error message follows the format "<staticMessage>: <optionalErr>", if optionalErr is not nil.
//
// It also logs `staticMessage` using softassert.Fail.
// `optionalErr` is added as a tag with key "softassert-error-details".
func UnexpectedDataLoss(logger log.Logger, staticMessage string, optionalErr error, tags ...tag.Tag) error {
// (1) trigger softassert
combinedTags := tags
if optionalErr != nil {
combinedTags = append([]tag.Tag{tag.NewErrorTag(errorDetailsTagName, optionalErr)}, tags...)
}
Fail(logger, staticMessage, combinedTags...)
// (2) return serviceerror
message := staticMessage
if optionalErr != nil {
message = fmt.Sprintf("%s: %s", staticMessage, optionalErr)
}
return serviceerror.NewDataLoss(message)
}