mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-27 15:41:42 +01:00
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:
committed by
GitHub
parent
7980e8e90a
commit
377c6c6e0d
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user