fix: Remove log.Fatal in favor of returning errors (#953)

* fix: Remove log.Fatal in favor of returning errors

This change is useful for including error tracking, which needs the
application to not terminate immediately, and instead give the tracer
time to capture and flush errors.

* Fix CodeRabbit issues

---------

Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
This commit is contained in:
Michael Manganiello
2025-08-23 14:09:40 -03:00
committed by GitHub
parent 7980e8e90a
commit 377c6c6e0d
4 changed files with 60 additions and 28 deletions

View File

@@ -3,6 +3,8 @@ package migrations
import (
"embed"
"fmt"
"github.com/rs/zerolog/log"
)
@@ -17,15 +19,16 @@ var sqliteFiles embed.FS
// migration files in the binary at build time. The function takes a string
// parameter "dialect" which specifies the SQL dialect to use. It returns an
// embedded file system containing the migration files for the specified dialect.
func Migrations(dialect string) embed.FS {
func Migrations(dialect string) (embed.FS, error) {
switch dialect {
case "postgres":
return postgresFiles
return postgresFiles, nil
case "sqlite3":
return sqliteFiles
return sqliteFiles, nil
default:
log.Fatal().Str("dialect", dialect).Msg("unknown sql dialect")
log.Error().Str("dialect", dialect).Msg("unknown sql dialect")
return embed.FS{}, fmt.Errorf("unknown sql dialect: %s", dialect)
}
// This should never get hit, but just in case
return sqliteFiles
return sqliteFiles, nil
}