Output the failing filename when showing a parse error (#13)

Co-authored-by: April Schleck <april@exclusivelyducks.com>
This commit is contained in:
April Schleck 2022-07-26 06:59:16 -07:00 committed by GitHub
parent b626ee119f
commit ce7a0b38ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ use std::{
path::Path,
};
use anyhow::{Context};
use clap::{Args, Parser};
use reshape::{
migrations::{Action, Migration},
@ -211,7 +212,8 @@ fn find_migrations(opts: &FindMigrationsOptions) -> anyhow::Result<Vec<Migration
.map(|result| {
result.and_then(|(path, data)| {
let extension = path.extension().and_then(|ext| ext.to_str()).unwrap();
let file_migration = decode_migration_file(&data, extension)?;
let file_migration = decode_migration_file(&data, extension)
.with_context(|| format!("failed to parse migration file {}", path.display()))?;
let file_name = path.file_stem().and_then(|name| name.to_str()).unwrap();
Ok(Migration {