fix(main): return 1 exit code on panic (#2590)

This commit is contained in:
Jo
2025-03-09 22:59:50 +01:00
committed by GitHub
parent a300330b94
commit 0b5f5f0ccd
3 changed files with 12 additions and 6 deletions

View File

@@ -43,6 +43,10 @@ func srcinfoExists(ctx context.Context,
return fmt.Errorf("unable to generate .SRCINFO: %w - %s", err, stderr)
}
if len(srcinfo) == 0 {
return fmt.Errorf("generated .SRCINFO is empty, check your PKGBUILD for errors")
}
if err := os.WriteFile(srcInfoDir, []byte(srcinfo), 0o600); err != nil {
return fmt.Errorf("unable to write .SRCINFO: %w", err)
}

View File

@@ -47,8 +47,9 @@ func main() {
defer func() {
if rec := recover(); rec != nil {
fallbackLog.Errorln(rec)
debug.PrintStack()
fallbackLog.Errorln("Panic occurred:", rec)
fallbackLog.Errorln("Stack trace:", string(debug.Stack()))
ret = 1
}
os.Exit(ret)
@@ -122,7 +123,8 @@ func main() {
defer func() {
if rec := recover(); rec != nil {
fallbackLog.Errorln(rec, string(debug.Stack()))
fallbackLog.Errorln("Panic occurred in DB operation:", rec)
fallbackLog.Errorln("Stack trace:", string(debug.Stack()))
}
dbExecutor.Cleanup()

6
vcs.go
View File

@@ -61,8 +61,8 @@ func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Exec
for iP := range srcinfos[i].Packages {
wg.Add(1)
go func(i string, iP int) {
run.VCSStore.Update(ctx, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source)
go func(baseIndex string, packageIndex int) {
run.VCSStore.Update(ctx, srcinfos[baseIndex].Packages[packageIndex].Pkgname, srcinfos[baseIndex].Source)
wg.Done()
}(i, iP)
}
@@ -71,5 +71,5 @@ func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Exec
wg.Wait()
run.Logger.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
return err
return nil
}