Skip to content

Commit

Permalink
Merge pull request golang-migrate#1103 from Shion1305/shion/issue-1102
Browse files Browse the repository at this point in the history
πŸ§‘β€πŸ’» improve error message for invalid source, database, resolves: golang-migrate#1102
  • Loading branch information
dhui authored Jun 10, 2024
2 parents b16220c + cabb2db commit 1585b87
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,25 @@ func New(sourceURL, databaseURL string) (*Migrate, error) {

sourceName, err := iurl.SchemeFromURL(sourceURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to parse scheme from source URL: %w", err)
}
m.sourceName = sourceName

databaseName, err := iurl.SchemeFromURL(databaseURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to parse scheme from database URL: %w", err)
}
m.databaseName = databaseName

sourceDrv, err := source.Open(sourceURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to open source, %q: %w", sourceURL, err)
}
m.sourceDrv = sourceDrv

databaseDrv, err := database.Open(databaseURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to open database, %q: %w", databaseURL, err)
}
m.databaseDrv = databaseDrv

Expand All @@ -131,7 +131,7 @@ func NewWithDatabaseInstance(sourceURL string, databaseName string, databaseInst

sourceDrv, err := source.Open(sourceURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to open source, %q: %w", sourceURL, err)
}
m.sourceDrv = sourceDrv

Expand All @@ -149,15 +149,15 @@ func NewWithSourceInstance(sourceName string, sourceInstance source.Driver, data

databaseName, err := iurl.SchemeFromURL(databaseURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to parse scheme from database URL: %w", err)
}
m.databaseName = databaseName

m.sourceName = sourceName

databaseDrv, err := database.Open(databaseURL)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to open database, %q: %w", databaseURL, err)
}
m.databaseDrv = databaseDrv

Expand Down

0 comments on commit 1585b87

Please sign in to comment.