Documentation
¶
Overview ¶
Package failure defines structured machine-readable terminal errors.
Index ¶
- func MarshalJSON(err error) ([]byte, error)
- func Prefix(err error, message string) error
- func Wrap(err error, code Code, stage Stage, message string, opts ...Option) error
- func WrapUnknown(err error, code Code, stage Stage, message string, opts ...Option) error
- type Code
- type Error
- type Option
- type Payload
- type Stage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON serializes any error into the machine-readable payload.
Types ¶
type Code ¶
type Code string
Code is a stable machine-readable failure identifier.
const ( CodeUnknown Code = "unknown_error" CodeInvalidArguments Code = "invalid_arguments" CodeInvalidTimeout Code = "invalid_timeout" CodeConfigInitializationFailed Code = "config_initialization_failed" CodeJavaRuntimeConfigInvalid Code = "java_runtime_config_invalid" CodeCacheInitializationFailed Code = "cache_initialization_failed" CodeRulesLoadFailed Code = "rules_load_failed" CodeScannerInitializationFailed Code = "scanner_initialization_failed" CodeScannerExecutionFailed Code = "scanner_execution_failed" CodeScannerTimeout Code = "scanner_timeout" CodeScannerCancelled Code = "scanner_canceled" CodeScannerOutputParseFailed Code = "scanner_output_parse_failed" CodeLanguageDetectionFailed Code = "language_detection_failed" CodeDependencyResolutionFailed Code = "dependency_resolution_failed" CodeDependencyBuildToolUnknown Code = "java_build_tool_unknown" CodeJavaBuildToolAmbiguous Code = "java_build_tool_ambiguous" CodeGradleToolMissing Code = "gradle_tool_missing" CodeGradleExportFailed Code = "gradle_export_failed" CodeGradleJavaIncompatible Code = "gradle_java_incompatible" CodeCallGraphBuildFailed Code = "callgraph_build_failed" CodeCallGraphExportFailed Code = "callgraph_export_failed" CodeOutputWriteFailed Code = "output_write_failed" CodeFindingsDetected Code = "findings_detected" )
Failure codes are stable machine-readable identifiers for terminal errors.
type Error ¶
type Error struct {
Code Code
Stage Stage
Retryable bool
Message string
Details map[string]string
Cause error
}
Error is a structured machine-readable terminal failure.
type Option ¶
type Option func(*Error)
Option configures a structured failure.
func WithDetail ¶
WithDetail adds a structured detail field.
func WithDetails ¶
WithDetails adds multiple structured detail fields.
func WithRetryable ¶
WithRetryable sets whether the failure should be retried.
type Payload ¶
type Payload struct {
Code Code `json:"code"`
Stage Stage `json:"stage"`
Retryable bool `json:"retryable"`
Message string `json:"message"`
Details map[string]string `json:"details,omitempty"`
Cause string `json:"cause,omitempty"`
RawError string `json:"raw_error,omitempty"`
}
Payload is the machine-readable representation emitted by CLI adapters.
type Stage ¶
type Stage string
Stage identifies the pipeline stage that produced the failure.
const ( StageUnknown Stage = "unknown" StageInput Stage = "input" StageConfig Stage = "config" StageRules Stage = "rules" StageScan Stage = "scan" StageDependency Stage = "dependency" StageCallGraph Stage = "callgraph" StageExport Stage = "export" StageOutput Stage = "output" StagePolicy Stage = "policy" )
Failure stages identify which pipeline phase produced a terminal error.