mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
57 lines
1.9 KiB
Go
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)
|
|
}
|