apperror

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package apperror 定义 CLI 与 HTTP API 共用的机器稳定领域错误。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code 是不随界面语言变化的错误码。

const (
	CodeTechnicalFailure            Code = "technical_failure"
	CodeWorkflowNotFound            Code = "workflow_not_found"
	CodeWorkflowAlreadyExists       Code = "workflow_already_exists"
	CodeRunNotFound                 Code = "run_not_found"
	CodeRunAlreadyExists            Code = "run_already_exists"
	CodeRunSummaryNotFound          Code = "run_summary_not_found"
	CodeWorkingDirectoryNotFound    Code = "working_directory_not_found"
	CodeWorkingDirectoryNotDir      Code = "working_directory_not_directory"
	CodeWorkflowValidationFailed    Code = "workflow_validation_failed"
	CodeRunNotStoppable             Code = "run_not_stoppable"
	CodeRunNotResumable             Code = "run_not_resumable"
	CodeRunNotDeletable             Code = "run_not_deletable"
	CodeWorkflowSaveConflict        Code = "workflow_save_conflict"
	CodeUserPromptRequired          Code = "user_prompt_required"
	CodeWorkingDirectoryMustBeAbs   Code = "working_directory_must_be_absolute"
	CodeNodeNotFound                Code = "node_not_found"
	CodeNodeAlreadyExists           Code = "node_already_exists"
	CodeReservedNodeID              Code = "reserved_node_id"
	CodeInvalidNodeID               Code = "invalid_node_id"
	CodeNodeDisplayNameRequired     Code = "node_display_name_required"
	CodeInvalidRequest              Code = "invalid_request"
	CodeInvalidSettingsRequest      Code = "invalid_settings_request"
	CodeUnsupportedMediaType        Code = "unsupported_media_type"
	CodeForbiddenOrigin             Code = "forbidden_origin"
	CodeDirectoryNotFound           Code = "directory_not_found"
	CodePathNotDirectory            Code = "path_not_directory"
	CodeEdgeNotFound                Code = "edge_not_found"
	CodeEdgeAlreadyExists           Code = "edge_already_exists"
	CodeWorkflowNameInvalidChars    Code = "workflow_name_invalid_characters"
	CodeWorkflowNameReserved        Code = "workflow_name_reserved"
	CodeRunIDInvalid                Code = "run_id_invalid"
	CodeNodesRequired               Code = "nodes_required"
	CodeDuplicateNodeID             Code = "duplicate_node_id"
	CodeStartNodeCount              Code = "start_node_count"
	CodeEndNodeCount                Code = "end_node_count"
	CodeAgentNodeRequired           Code = "agent_node_required"
	CodeMarkerFieldNotEmpty         Code = "marker_field_not_empty"
	CodeRequiredField               Code = "required_field"
	CodeEdgeEndpointsRequired       Code = "edge_endpoints_required"
	CodeEdgeFromNodeNotFound        Code = "edge_from_node_not_found"
	CodeEdgeToNodeNotFound          Code = "edge_to_node_not_found"
	CodeSelfEdge                    Code = "self_edge"
	CodeStartEndDirectEdge          Code = "start_end_direct_edge"
	CodeEdgeToStart                 Code = "edge_to_start"
	CodeEdgeFromEnd                 Code = "edge_from_end"
	CodeDuplicateEdge               Code = "duplicate_edge"
	CodeCycleDetected               Code = "cycle_detected"
	CodeNodeMissingIncomingEdge     Code = "node_missing_incoming_edge"
	CodeNodeMissingOutgoingEdge     Code = "node_missing_outgoing_edge"
	CodeUnknownSystemVariable       Code = "unknown_system_variable"
	CodeMarkerNodeReference         Code = "marker_node_reference"
	CodeNonAncestorNodeReference    Code = "non_ancestor_node_reference"
	CodeNodeReferenceNotFound       Code = "node_reference_not_found"
	CodeUnknownEngine               Code = "unknown_engine"
	CodeEngineModelNotAllowed       Code = "engine_model_not_allowed"
	CodeEngineEffortFieldNotAllowed Code = "engine_effort_field_not_allowed"
	CodeEngineEffortValueNotAllowed Code = "engine_effort_value_not_allowed"
)

func AllCodes

func AllCodes() []Code

AllCodes 返回所有需要由 CLI 和 UI 渲染的稳定错误码。

func CodeOf

func CodeOf(err error) (Code, bool)

CodeOf 返回错误链中的稳定错误码。

type Error

type Error struct {
	Code            Code      `json:"code"`
	Params          Params    `json:"params,omitempty"`
	Problems        []Problem `json:"problems,omitempty"`
	TechnicalDetail string    `json:"technicalDetail,omitempty"`
	// contains filtered or unexported fields
}

Error 是领域错误或带技术详情的技术错误。

func As

func As(err error) (*Error, bool)

As 返回错误链中的结构化错误。

func New

func New(code Code, params Params) *Error

func Technical

func Technical(detail string, cause error) *Error

func Technicalf

func Technicalf(cause error, format string, arguments ...any) *Error

func Validation

func Validation(problems []Problem) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Params

type Params map[string]any

Params 是错误模板的结构化参数。值仅使用 JSON 可编码的标量或切片。

type Problem

type Problem struct {
	Path   string `json:"path"`
	Code   Code   `json:"code"`
	Params Params `json:"params,omitempty"`
}

Problem 是批量校验中的一条字段错误。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL