From 74fa6d4962476f91d21929a3065f398f5ca6b67e Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 11 Nov 2016 17:09:51 -0800 Subject: [PATCH] Include line in all error messages (#51) I had previously not included the line for some error messages, but I don't think that I had a good reason why, and they look pretty good, so adding them back for consistency. --- src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7d8a774..00b4ea1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -774,13 +774,15 @@ impl<'a> Display for Error<'a> { if circle.len() == 2 { try!(write!(f, "recipe `{}` depends on itself", recipe)); } else { - try!(write!(f, "recipe `{}` has circular dependency `{}`", recipe, circle.join(" -> "))); + try!(writeln!(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(" -> "))); - return Ok(()); + if circle.len() == 2 { + try!(writeln!(f, "variable `{}` depends on its own value: `{}`", variable, circle.join(" -> "))); + } else { + try!(writeln!(f, "variable `{}` depends on its own value: `{}`", variable, circle.join(" -> "))); + } } ErrorKind::InvalidEscapeSequence{character} => { try!(writeln!(f, "`\\{}` is not a valid escape sequence", character.escape_default().collect::())); @@ -798,9 +800,8 @@ impl<'a> Display for Error<'a> { try!(writeln!(f, "recipe `{}` has duplicate dependency `{}`", recipe, dependency)); } ErrorKind::DuplicateRecipe{recipe, first} => { - try!(write!(f, "recipe `{}` first defined on line {} is redefined on line {}", + try!(writeln!(f, "recipe `{}` first defined on line {} is redefined on line {}", recipe, first, self.line)); - return Ok(()); } ErrorKind::DependencyHasParameters{recipe, dependency} => { try!(writeln!(f, "recipe `{}` depends on `{}` which requires arguments. dependencies may not require arguments", recipe, dependency));