Skip to content

Commit

Permalink
Improve error reporting for 'elp project-info'
Browse files Browse the repository at this point in the history
Summary:
The `elp project-info` command is typically used when trying to debug project configuration.
As such, it should report any errors it finds, rather than swallowing them.

So if loading of the discovered project manifest fails, report the details before falling back to the alternative.

Reviewed By: TheGeorge

Differential Revision: D57440402

fbshipit-source-id: 6b199b89343d67a9bffaeb8c7b7a3829d74fe559
  • Loading branch information
alanz authored and facebook-github-bot committed May 20, 2024
1 parent 5d6b729 commit e7a2948
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions crates/elp/src/bin/build_info_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ pub(crate) fn save_build_info(args: BuildInfo, query_config: &BuckQueryConfig) -
}

pub(crate) fn save_project_info(args: ProjectInfo, query_config: &BuckQueryConfig) -> Result<()> {
let root = fs::canonicalize(&args.project)?;
let root = AbsPathBuf::assert(root);
let (manifest, project) =
load_project(&root, query_config).or_else(|_| load_fallback(&root, query_config))?;

let mut writer: Box<dyn Write> = match args.to {
Some(to) => Box::new(
std::fs::OpenOptions::new()
Expand All @@ -64,6 +59,18 @@ pub(crate) fn save_project_info(args: ProjectInfo, query_config: &BuckQueryConfi
),
None => Box::new(std::io::stdout()),
};
let root = fs::canonicalize(&args.project)?;
let root = AbsPathBuf::assert(root);
let (manifest, project) = match load_project(&root, query_config) {
Ok(res) => res,
Err(err) => {
writer.write_all(
format!("could not load manifest:\n-----\n{err},\n-----\nfalling back\n")
.as_bytes(),
)?;
load_fallback(&root, query_config)?
}
};

if args.buck_query {
if let ProjectBuildData::Buck(buck) = &project.project_build_data {
Expand Down

0 comments on commit e7a2948

Please sign in to comment.