Skip to content

Commit c86e3d0

Browse files
committed
remove panic on failed parse
1 parent 6bc55aa commit c86e3d0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler-cli/src/dependencies.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,24 +1097,25 @@ async fn lookup_package(
10971097
let cache_path = global_hexpm_package_release_response_cache(&name, &version.to_string());
10981098
let release = match release {
10991099
Ok(rel) => {
1100-
// save
1101-
// FIXME: I may not need to wright every time
11021100
let _ = fs.write_bytes(&cache_path, &resp_body);
11031101
rel
11041102
},
11051103
Err(_) => {
1106-
// load
11071104
let cached_result = fs.read_bytes(&cache_path)
11081105
.map_err(|err| Error::FileIo {
11091106
action: FileIoAction::Read,
11101107
kind: FileKind::File,
1111-
path: cache_path,
1108+
path: cache_path.clone(),
11121109
err: Some(err.to_string()),
11131110
})?;
11141111

1115-
// FIXME: I crash when the cache is bad
1116-
// author note
1117-
serde_json::from_slice(&cached_result).expect("cache bad")
1112+
serde_json::from_slice(&cached_result)
1113+
.map_err(|err| Error::FileIo {
1114+
action: FileIoAction::Read,
1115+
kind: FileKind::File,
1116+
path: cache_path,
1117+
err: Some(err.to_string()),
1118+
})?
11181119
}
11191120
};
11201121
let build_tools = release

0 commit comments

Comments
 (0)