Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Gracefully recover Go migrations that panic #643

Merged
merged 2 commits into from
Nov 12, 2023

Conversation

mfridman
Copy link
Collaborator

Fix #642.

A nice quality of life improvement, add a recover when running Go migrations with the Provider.

@mfridman mfridman merged commit 1e40462 into master Nov 12, 2023
@mfridman mfridman deleted the gh642-panic-recover branch November 12, 2023 17:06
func runGo(ctx context.Context, db database.DBTxConn, m *Migration, direction bool) (retErr error) {
defer func() {
if r := recover(); r != nil {
retErr = fmt.Errorf("panic: %v\n%s", r, debug.Stack())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default Go stack is a bit noisy, wonder if there's an opportunity here to clean this up a bit, i.e., pretty print stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider: add recover function for Go migrations to gracefully handle panics
1 participant