Adopt the native CommandKit application boundary

This commit is contained in:
2026-11-20 04:13:05 +00:00
parent 86692d58f9
commit a3c58141a0
25 changed files with 420 additions and 148 deletions

View File

@@ -0,0 +1,49 @@
package app
import (
"go.maximumdirect.net/ckconfig"
"go.maximumdirect.net/commandkit"
)
// inputError identifies an invalid Narratio request independently of native
// configuration diagnostics. Operational errors retain their own classification.
type inputError struct{ message string }
func (e *inputError) Error() string { return e.message }
func operationOutcome(err error) commandkit.Outcome {
if err == nil {
return commandkit.Success()
}
if classifyOperationError(err) == commandkit.OutcomeUsage {
return commandkit.Usage(err.Error()).WithCause(err)
}
return commandkit.Failure(err.Error()).WithCause(err)
}
func classifyOperationError(err error) commandkit.OutcomeKind {
if _, ok := err.(*inputError); ok {
return commandkit.OutcomeUsage
}
switch wrapped := err.(type) {
case interface{ Unwrap() []error }:
found := false
for _, child := range wrapped.Unwrap() {
if child == nil {
continue
}
found = true
if classifyOperationError(child) != commandkit.OutcomeUsage {
return commandkit.OutcomeOperational
}
}
if found {
return commandkit.OutcomeUsage
}
case interface{ Unwrap() error }:
if child := wrapped.Unwrap(); child != nil {
return classifyOperationError(child)
}
}
return ckconfig.ClassifyConfigurationError(err)
}