Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#### :nail_care: Polish

- Improve error message for dependency without `rescript.json`. https://github.com/rescript-lang/rescript/issues/8265

#### :house: Internal

- Reanalyze server: redesign incremental fixpoint with delete-then-rederive strategy and predecessor tracking, improving speed on deletions. https://github.com/rescript-lang/rescript/pull/8276
Expand Down
4 changes: 2 additions & 2 deletions rewatch/src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fn read_dependencies(

let parent_path_str = project_context.get_root_path().to_string_lossy();
log::error!(
"We could not build package tree reading dependency '{package_name}', at path '{parent_path_str}'. Error: {error}",
"Could not build package tree reading dependency '{package_name}' at path '{parent_path_str}'. Error: {error}",
);

std::process::exit(2)
Expand All @@ -363,7 +363,7 @@ fn read_dependencies(
Err(error) => {
let parent_path_str = project_context.get_root_path().to_string_lossy();
log::error!(
"We could not build package tree '{package_name}', at path '{parent_path_str}'. Error: {error}",
"Could not build package tree for '{package_name}' at path '{parent_path_str}'. Error: {error}",
);
std::process::exit(2)
}
Expand Down
13 changes: 12 additions & 1 deletion rewatch/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ fn namespace_from_package_name(package_name: &str) -> String {
impl Config {
/// Try to convert a config from a certain path to a config struct
pub fn new(path: &Path) -> Result<Self> {
let read = fs::read_to_string(path)?;
let read =
fs::read_to_string(path).map_err(|e| anyhow!("Could not read '{}': {}", path.display(), e))?;
let mut config = Config::new_from_json_string(&read)?;
config.set_path(path.to_path_buf())?;
Ok(config)
Expand Down Expand Up @@ -1490,4 +1491,14 @@ pub mod tests {
let args = config.get_warning_args(false, Some("+3+8+11".to_string()));
assert_eq!(args, Vec::<String>::new());
}

#[test]
fn test_new_missing_rescript_json() {
let path = PathBuf::from("/nonexistent/path/rescript.json");
let error = Config::new(&path).unwrap_err().to_string();
assert!(
error.contains(path.to_string_lossy().as_ref()),
"Error should include the missing config path, got: {error}"
);
}
}
Loading