Skip to content

Commit

Permalink
chore(solc): include error code in diagnostic (gakonst#1171)
Browse files Browse the repository at this point in the history
mattsse authored Apr 23, 2022
1 parent 1cba287 commit f4eb402
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ethers-solc/src/artifacts/mod.rs
Original file line number Diff line number Diff line change
@@ -1281,8 +1281,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)?;
2 changes: 2 additions & 0 deletions ethers-solc/src/compile/output.rs
Original file line number Diff line number Diff line change
@@ -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],
}

0 comments on commit f4eb402

Please sign in to comment.