Skip to content

Commit 5705121

Browse files
chore: clean up error! calls (#273)
I got a `ERROR` log when using `forge flatten` with no extra message, and the error itself gets ignored with a fallback --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
1 parent 67d148f commit 5705121

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

crates/compilers/src/artifact_output/mod.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,8 @@ pub trait ArtifactOutput {
625625
) -> Result<Artifacts<Self::Artifact>> {
626626
let mut artifacts =
627627
self.output_to_artifacts(contracts, sources, ctx, layout, primary_profiles);
628-
fs::create_dir_all(&layout.artifacts).map_err(|err| {
629-
error!(dir=?layout.artifacts, "Failed to create artifacts folder");
630-
SolcIoError::new(err, &layout.artifacts)
631-
})?;
628+
fs::create_dir_all(&layout.artifacts)
629+
.map_err(|err| SolcIoError::new(err, &layout.artifacts))?;
632630

633631
artifacts.join_all(&layout.artifacts);
634632
artifacts.write_all()?;
@@ -1140,16 +1138,17 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback {
11401138
}
11411139

11421140
fn read_cached_artifact(path: &Path) -> Result<Self::Artifact> {
1143-
let content = fs::read_to_string(path).map_err(|err| SolcError::io(err, path))?;
1144-
if let Ok(a) = serde_json::from_str(&content) {
1145-
Ok(a)
1146-
} else {
1147-
error!("Failed to deserialize compact artifact");
1148-
trace!("Fallback to hardhat artifact deserialization");
1149-
let artifact = serde_json::from_str::<HardhatArtifact>(&content)?;
1150-
trace!("successfully deserialized hardhat artifact");
1151-
Ok(artifact.into_contract_bytecode())
1141+
#[derive(Deserialize)]
1142+
#[serde(untagged)]
1143+
enum Artifact {
1144+
Compact(CompactContractBytecode),
1145+
Hardhat(HardhatArtifact),
11521146
}
1147+
1148+
Ok(match utils::read_json_file::<Artifact>(path)? {
1149+
Artifact::Compact(c) => c,
1150+
Artifact::Hardhat(h) => h.into_contract_bytecode(),
1151+
})
11531152
}
11541153

11551154
fn contract_to_artifact(

crates/compilers/src/compilers/solc/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub static RELEASES: std::sync::LazyLock<(svm::Releases, Vec<Version>, bool)> =
5454
(releases, sorted_versions, true)
5555
}
5656
Err(err) => {
57-
error!("{:?}", err);
57+
error!("failed to deserialize SVM static RELEASES JSON: {err}");
5858
Default::default()
5959
}
6060
}

crates/compilers/src/resolver/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,9 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
917917
.collect(),
918918
);
919919
} else {
920-
error!("failed to resolve versions");
921-
return Err(SolcError::msg(errors.join("\n")));
920+
let s = errors.join("\n");
921+
debug!("failed to resolve versions: {s}");
922+
return Err(SolcError::msg(s));
922923
}
923924
}
924925

@@ -960,8 +961,9 @@ impl<L: Language, D: ParsedSource<Language = L>> Graph<D> {
960961
if errors.is_empty() {
961962
Ok(resulted_sources)
962963
} else {
963-
error!("failed to resolve settings");
964-
Err(SolcError::msg(errors.join("\n")))
964+
let s = errors.join("\n");
965+
debug!("failed to resolve settings: {s}");
966+
Err(SolcError::msg(s))
965967
}
966968
}
967969

0 commit comments

Comments
 (0)