Wire process identity cancellation and shared HTTP server lifecycle
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"go.maximumdirect.net/ckconfig"
|
||||
"go.maximumdirect.net/commandkit"
|
||||
"go.maximumdirect.net/configkit"
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
@@ -19,6 +20,16 @@ func completedRunOutcome(result *promptkit.RunResult) commandkit.Outcome {
|
||||
return commandkit.Success()
|
||||
}
|
||||
|
||||
func frameworkFailure(reporter *commandkit.Reporter, err error, explanation commandkit.Explanation) commandkit.Outcome {
|
||||
var native *configkit.LoadError
|
||||
if errors.As(err, &native) && native != nil {
|
||||
diagnostics, terminal := ckconfig.AdaptDiagnostics("PromptKit configuration:\n", native.Sources(), native.Diagnostics())
|
||||
queueDiagnostics(reporter, diagnostics)
|
||||
explanation.Details = append(explanation.Details, terminal.Details...)
|
||||
}
|
||||
return requestFailure(err, explanation)
|
||||
}
|
||||
|
||||
func requestFailure(err error, explanation commandkit.Explanation) commandkit.Outcome {
|
||||
message := "The requested operation failed."
|
||||
switch {
|
||||
@@ -27,7 +38,7 @@ func requestFailure(err error, explanation commandkit.Explanation) commandkit.Ou
|
||||
case errors.Is(err, context.Canceled):
|
||||
message = "The operation was canceled."
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
message = "The caller deadline expired."
|
||||
message = "A request deadline expired."
|
||||
default:
|
||||
if ckconfig.ClassifyConfigurationError(err) == commandkit.OutcomeUsage {
|
||||
return commandkit.Usage("Invalid configuration.", explanation.Details...).WithCause(err)
|
||||
|
||||
Reference in New Issue
Block a user