Skip to content
Open
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
8 changes: 4 additions & 4 deletions jed.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,25 +451,25 @@ in order to offer easy upgrades -- jsgettext.berlios.de
field_list.push(field_match[1]);
}
else {
throw('[sprintf] huh?');
throw('[sprintf] Named placeholders should only contain valid identifiers.');
}
}
}
else {
throw('[sprintf] huh?');
throw('[sprintf] Named placeholders should only contain valid identifiers.');
}
match[2] = field_list;
}
else {
arg_names |= 2;
}
if (arg_names === 3) {
throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
throw('[sprintf] mixing positional and named placeholders is not (yet) supported.');
}
parse_tree.push(match);
}
else {
throw('[sprintf] huh?');
throw('[sprintf] Found percentage-sign, but it wasn\'t a valid placeholder or escaped percentage-sign.');
}
_fmt = _fmt.substring(match[0].length);
}
Expand Down
5 changes: 5 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@
expect(i18n.sprintf(i, arg)).to.be(strings[i]);
}
});

it("should give meaningfull error messages", function() {
expect(Jed.sprintf.bind(null, "5%", {})).to.throwException(/^\[sprintf\] Found percentage-sign, but it wasn't a valid placeholder or escaped percentage-sign.$/);
expect(Jed.sprintf.bind(null, "%(1invalid)s", {})).to.throwException(/^\[sprintf\] Named placeholders should only contain valid identifiers.$/);
});
});
})();

Expand Down