Include names in unit assertion errors.

This commit is contained in:
Natalie Weizenbaum 2017-01-08 21:26:05 -08:00
parent 28c7362016
commit 7564b6a51a

View File

@ -278,7 +278,7 @@ class SassNumber extends Value {
/// (without the `$`). It's used for debugging. /// (without the `$`). It's used for debugging.
void assertUnit(String unit, [String name]) { void assertUnit(String unit, [String name]) {
if (hasUnit(unit)) return; if (hasUnit(unit)) return;
throw _exception('Expected $this to have unit "$unit".'); throw _exception('Expected $this to have unit "$unit".', name);
} }
/// Throws a [SassScriptException] unless [this] has no units. /// Throws a [SassScriptException] unless [this] has no units.
@ -287,7 +287,7 @@ class SassNumber extends Value {
/// (without the `$`). It's used for debugging. /// (without the `$`). It's used for debugging.
void assertNoUnits([String name]) { void assertNoUnits([String name]) {
if (!hasUnits) return; if (!hasUnits) return;
throw _exception('Expected $this to have no units.'); throw _exception('Expected $this to have no units.', name);
} }
/// Returns a copy of this number, converted to the units represented by /// Returns a copy of this number, converted to the units represented by