Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Improve JSON errors debuggability #394

Merged
merged 2 commits into from
Aug 5, 2019
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
3 changes: 1 addition & 2 deletions src/commands/build/wranglerjs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub fn run_build(project: &Project) -> Result<(), failure::Error> {

if status.success() {
let output = fs::read_to_string(temp_file.clone()).expect("could not retrieve ouput");
fs::remove_file(temp_file)?;

let wranglerjs_output: WranglerjsOutput =
serde_json::from_str(&output).expect("could not parse wranglerjs output");
Expand All @@ -54,10 +53,10 @@ pub fn run_build(project: &Project) -> Result<(), failure::Error> {
wranglerjs_output.project_size()
);

fs::remove_file(temp_file)?;
message::success(&msg);
Ok(())
} else {
fs::remove_file(temp_file)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are preserving this for forensic purposes, should we output its location?

Copy link
Member Author

@xtuc xtuc Aug 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that "forensic purposes" is similar to post mortem analysis, in that case yes. The location is available when using RUST_LOG=info. The user doesn't need to know about its exisiance.

failure::bail!("failed to execute `{:?}`: exited with {}", command, status)
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/publish/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ impl Package {
)
}

let package_json: String = fs::read_to_string(manifest_path)?.parse()?;
let package: Package = serde_json::from_str(&package_json)?;
let package_json: String = fs::read_to_string(manifest_path.clone())?.parse()?;
let package: Package = serde_json::from_str(&package_json)
.expect(&format!("could not parse {:?}", manifest_path));

Ok(package)
}
Expand Down
6 changes: 5 additions & 1 deletion src/commands/publish/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ pub fn preview(
.send()?
.error_for_status();

let p: Preview = serde_json::from_str(&res?.text()?)?;
let text = &res?.text()?;
log::info!("Response from preview: {:?}", text);

let p: Preview =
serde_json::from_str(text).expect("could not create a script on cloudflareworkers.com");

let session = Uuid::new_v4().to_simple();

Expand Down