fix: replace panic() with log.Fatalf() in init functions#338
Open
1Ckpwee wants to merge 1 commit into
Open
Conversation
Replace panic() with log.Fatalf() in package init functions for cleaner error output on startup failures. Panic produces a goroutine stack trace that obscures the actual error, while log.Fatalf provides a clear message and clean exit. Changes: - app/shared/ai_models_available.go: replace 10 panic() calls in model validation with log.Fatalf() and add descriptive prefixes - app/server/db/fs.go: replace panic in home dir lookup with log.Fatalf - app/server/db/git.go: replace panic in git availability check with log.Fatalf Fixes plandex-ai#337
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #337
Replaces
panic()calls withlog.Fatalf()in threeinit()functions. Panics produce noisy goroutine stack traces that obscure the actual error.log.Fatalf()logs a clear message and exits cleanly.Changes
app/shared/ai_models_available.go: 10panic()→log.Fatalf()in model validation loop, with"model validation failed: "prefixapp/server/db/fs.go:panic(fmt.Errorf(...))→log.Fatalf(...)for home dir detectionapp/server/db/git.go:panic(fmt.Errorf(...))→log.Fatalf(...)for git availability checkRationale
Since these are
init()functions (cannot return errors),log.Fatalf()is the appropriate replacement — it provides a clean error message andos.Exit(1)instead of a panic trace.Test plan
go build ./...