[#7781] added panic stack trace to routine.SafeWrap and wrapped JSVM migrate arguments so that we can return a clean error with the failed filename

This commit is contained in:
Gani Georgiev
2026-09-15 17:39:59 +03:00
parent 457e094d41
commit 86ce1be8fe
10 changed files with 42 additions and 13 deletions
+21 -1
View File
@@ -218,7 +218,27 @@ func (p *plugin) registerMigrations() error {
vm.Set("__hooks", absHooksDir)
vm.Set("migrate", func(up, down func(txApp core.App) error) {
core.AppMigrations.Register(up, down, file)
// note: safe wrap to capture any eventual panic and to allow
// the error message to print the migration filename
core.AppMigrations.Register(
func(txApp core.App) error {
return routine.SafeWrap(func() error {
if up == nil {
return nil
}
return up(txApp)
})()
},
func(txApp core.App) error {
return routine.SafeWrap(func() error {
if down == nil {
return nil
}
return down(txApp)
})()
},
file,
)
})
if p.config.OnInit != nil {