assertUnit method

void assertUnit(
  1. String unit, [
  2. String? name
])

Throws a SassScriptException unless this has unit as its only unit (and as a numerator).

If this came from a function argument, name is the argument name (without the $). It's used for error reporting.

Implementation

void assertUnit(String unit, [String? name]) {
  if (hasUnit(unit)) return;
  throw SassScriptException('Expected $this to have unit "$unit".', name);
}