}
Some((_, '}')) if self.depth == 0 => {
self.cur.next();
- self.err(~"unmatched `}` found");
+ self.err("unmatched `}` found");
None
}
Some((_, '}')) | None => { None }
/// Notifies of an error. The message doesn't actually need to be of type
/// ~str, but I think it does when this eventually uses conditions so it
/// might as well start using it now.
- fn err(&self, msg: ~str) {
- parse_error::cond.raise(msg);
+ fn err(&self, msg: &str) {
+ parse_error::cond.raise("invalid format string: " + msg);
}
/// Optionally consumes the specified character. If the character is not at
self.cur.next();
}
Some((_, other)) => {
- parse_error::cond.raise(
+ self.err(
format!("expected `{}` but found `{}`", c, other));
}
None => {
- parse_error::cond.raise(
+ self.err(
format!("expected `{}` but string was terminated", c));
}
}
c
}
None => {
- self.err(~"expected an escape sequence, but format string was \
+ self.err("expected an escape sequence, but format string was \
terminated");
' '
}
Some(self.plural())
}
"" => {
- self.err(~"expected method after comma");
+ self.err("expected method after comma");
return None;
}
method => {
self.ws();
let selector = self.word();
if selector == "" {
- self.err(~"cannot have an empty selector");
+ self.err("cannot have an empty selector");
break
}
self.must_consume('{');
self.must_consume('}');
if selector == "other" {
if !other.is_none() {
- self.err(~"multiple `other` statements in `select");
+ self.err("multiple `other` statements in `select");
}
other = Some(pieces);
} else {
let other = match other {
Some(arm) => { arm }
None => {
- self.err(~"`select` statement must provide an `other` case");
+ self.err("`select` statement must provide an `other` case");
~[]
}
};
match self.integer() {
Some(i) => { offset = Some(i); }
None => {
- self.err(~"offset must be an integer");
+ self.err("offset must be an integer");
}
}
}
match self.integer() {
Some(i) => Right(i),
None => {
- self.err(~"plural `=` selectors must be followed by an \
- integer");
+ self.err("plural `=` selectors must be followed by an \
+ integer");
Right(0)
}
}
self.must_consume('}');
if isother {
if !other.is_none() {
- self.err(~"multiple `other` statements in `select");
+ self.err("multiple `other` statements in `select");
}
other = Some(pieces);
} else {
let other = match other {
Some(arm) => { arm }
None => {
- self.err(~"`plural` statement must provide an `other` case");
+ self.err("`plural` statement must provide an `other` case");
~[]
}
};