From 58fb70e16e1637d146080aeaa159fdb6e6d5605f Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 28 Oct 2016 20:40:16 -0700 Subject: [PATCH] Surround tokens with `` in errors --- src/integration.rs | 2 +- src/lib.rs | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/integration.rs b/src/integration.rs index de9e5ab..9850116 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -207,7 +207,7 @@ fn error() { "bar:\nhello:\nfoo: bar baaaaaaaz hello", 255, "", - "error: recipe foo has unknown dependency baaaaaaaz + "error: recipe `foo` has unknown dependency `baaaaaaaz` | 3 | foo: bar baaaaaaaz hello | ^^^^^^^^^ diff --git a/src/lib.rs b/src/lib.rs index 7cefa66..abf17fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -483,46 +483,46 @@ impl<'a> Display for Error<'a> { match self.kind { ErrorKind::BadName{name} => { - try!(writeln!(f, "name did not match /[a-z](-?[a-z0-9])*/: {}", name)); + try!(writeln!(f, "name `{}` did not match /[a-z](-?[a-z0-9])*/", name)); } ErrorKind::CircularRecipeDependency{recipe, ref circle} => { if circle.len() == 2 { - try!(write!(f, "recipe {} depends on itself:", recipe)); + try!(write!(f, "recipe `{}` depends on itself", recipe)); } else { - try!(write!(f, "recipe {} has circular dependency: {}", recipe, circle.join(" -> "))); + try!(write!(f, "recipe `{}` has circular dependency `{}`", recipe, circle.join(" -> "))); } return Ok(()); } ErrorKind::CircularVariableDependency{variable, ref circle} => { - try!(write!(f, "assignment to {} has circular dependency: {}", variable, circle.join(" -> "))); + try!(write!(f, "assignment to `{}` has circular dependency: `{}`", variable, circle.join(" -> "))); return Ok(()); } ErrorKind::InvalidEscapeSequence{character} => { - try!(writeln!(f, "\\{}", character.escape_default().collect::())); + try!(writeln!(f, "`\\{}` is not a valid escape sequence", character.escape_default().collect::())); } ErrorKind::DuplicateArgument{recipe, argument} => { - try!(writeln!(f, "recipe {} has duplicate argument: {}", recipe, argument)); + try!(writeln!(f, "recipe `{}` has duplicate argument `{}`", recipe, argument)); } ErrorKind::DuplicateVariable{variable} => { - try!(writeln!(f, "variable \"{}\" is has multiple definitions", variable)); + try!(writeln!(f, "variable `{}` is has multiple definitions", variable)); } ErrorKind::UnexpectedToken{ref expected, found} => { try!(writeln!(f, "expected {} but found {}", Or(expected), found)); } ErrorKind::DuplicateDependency{recipe, dependency} => { - try!(writeln!(f, "recipe {} has duplicate dependency: {}", recipe, dependency)); + try!(writeln!(f, "recipe `{}` has duplicate dependency `{}`", recipe, dependency)); } ErrorKind::DuplicateRecipe{recipe, first} => { - try!(write!(f, "duplicate recipe: {} appears on lines {} and {}", + try!(write!(f, "recipe `{}` first defined on line {} is redefined on line {}", recipe, first, self.line)); return Ok(()); } ErrorKind::ArgumentShadowsVariable{argument} => { - try!(writeln!(f, "argument {} shadows variable of the same name", argument)); + try!(writeln!(f, "argument `{}` shadows variable of the same name", argument)); } ErrorKind::MixedLeadingWhitespace{whitespace} => { try!(writeln!(f, - "found a mix of tabs and spaces in leading whitespace: {}\n leading whitespace may consist of tabs or spaces, but not both", + "found a mix of tabs and spaces in leading whitespace: `{}`\n leading whitespace may consist of tabs or spaces, but not both", show_whitespace(whitespace) )); } @@ -531,18 +531,18 @@ impl<'a> Display for Error<'a> { } ErrorKind::InconsistentLeadingWhitespace{expected, found} => { try!(writeln!(f, - "inconsistant leading whitespace: recipe started with \"{}\" but found line with \"{}\":", + "inconsistant leading whitespace: recipe started with `{}` but found line with `{}`:", show_whitespace(expected), show_whitespace(found) )); } ErrorKind::OuterShebang => { - try!(writeln!(f, "a shebang \"#!\" is reserved syntax outside of recipes")) + try!(writeln!(f, "a shebang `#!` is reserved syntax outside of recipes")) } ErrorKind::UnknownDependency{recipe, unknown} => { - try!(writeln!(f, "recipe {} has unknown dependency {}", recipe, unknown)); + try!(writeln!(f, "recipe `{}` has unknown dependency `{}`", recipe, unknown)); } ErrorKind::UnknownVariable{variable} => { - try!(writeln!(f, "variable \"{}\" is unknown", variable)); + try!(writeln!(f, "variable `{}` is unknown", variable)); } ErrorKind::UnknownStartOfToken => { try!(writeln!(f, "unknown start of token:"));