Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

chore(solc): include error code in diagnostic #1171

Merged
merged 1 commit into from
Apr 23, 2022
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
14 changes: 12 additions & 2 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,18 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(msg) = &self.formatted_message {
match self.severity {
Severity::Error => msg.as_str().red().fmt(f),
Severity::Warning | Severity::Info => msg.as_str().yellow().fmt(f),
Severity::Error => {
if let Some(code) = self.error_code {
format!("error[{}]: ", code).as_str().red().fmt(f)?;
}
msg.as_str().red().fmt(f)
}
Severity::Warning | Severity::Info => {
if let Some(code) = self.error_code {
format!("warning[{}]: ", code).as_str().yellow().fmt(f)?;
}
msg.as_str().yellow().fmt(f)
}
}
} else {
self.severity.fmt(f)?;
Expand Down
2 changes: 2 additions & 0 deletions ethers-solc/src/compile/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ impl AggregatedCompilerOutput {
/// Helper type to implement display for solc errors
#[derive(Clone, Debug)]
pub struct OutputDiagnostics<'a> {
/// output of the compiled project
compiler_output: &'a AggregatedCompilerOutput,
/// the error codes to ignore
ignored_error_codes: &'a [u64],
}

Expand Down