Skip to content

Commit

Permalink
cli: use more specific error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lw2011 committed Oct 17, 2022
1 parent 82eea69 commit 2c9a8df
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions refinery_cli/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ fn run_migrations(
let mut migrations = Vec::new();
for path in migration_files_path {
let sql = std::fs::read_to_string(path.as_path())
.with_context(|| format!("could not read migration file name {}", path.display()))?;
.with_context(|| format!("Could not read contents of file {}", path.display()))?;

//safe to call unwrap as find_migration_filenames returns canonical paths
let filename = path
.file_name()
.and_then(|file| file.to_os_string().into_string().ok())
.unwrap();

let migration = Migration::unapplied(&filename, &sql)
.with_context(|| format!("could not read migration file name {}", path.display()))?;
let migration = Migration::unapplied(&filename, &sql).with_context(|| {
format!(
"Could not create new unapplied migration with filename {}",
path.display()
)
})?;
migrations.push(migration);
}
let mut config = config(config_location, env_var_opt)?;
Expand Down

0 comments on commit 2c9a8df

Please sign in to comment.