From 72ac39cb2bac5c176dd1277c9482334d0441286f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 10 Jun 2026 23:59:21 +0300 Subject: Replace panics with returned errors in llm.RegisterProvider RegisterProvider now returns an error for an empty name, a nil factory, or a duplicate registration instead of panicking, making registration composable and testable without recover(). RegisterAllProviders caches the one-time registration error (sync.Once cannot return a value) and returns it to every caller. Updated all call sites: hexailsp, hexaicli and hexaiaction propagate the error with context; test TestMains fail fast via panic. Added unit tests covering empty name, nil factory, duplicate, success and idempotent re-registration. Co-Authored-By: Claude Opus 4.8 --- internal/hexaiaction/cmdentry.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/hexaiaction') diff --git a/internal/hexaiaction/cmdentry.go b/internal/hexaiaction/cmdentry.go index d60f172..ee78307 100644 --- a/internal/hexaiaction/cmdentry.go +++ b/internal/hexaiaction/cmdentry.go @@ -25,7 +25,9 @@ type Options struct { // RunCommand is the CLI orchestrator used by cmd/hexai-tmux-action. It runs in tmux // split-pane mode by default, or child mode when -ui-child is set. func RunCommand(ctx context.Context, opts Options, stdin io.Reader, stdout, stderr io.Writer) error { - llm.RegisterAllProviders() + if err := llm.RegisterAllProviders(); err != nil { + return fmt.Errorf("failed to register LLM providers: %w", err) + } if opts.UIChild { return runChild(ctx, opts.Infile, opts.Outfile, stdout, stderr) } -- cgit v1.2.3