Sass @error Rules

Last Updated:

Sass @error Rules

When writing @function and @mixin that takes a dynamically generated value as an argument, you usually want to throw an error and stop further execution when the types or formats of the argument doesn't match your needs.

In the following example, @error will throw an error and stop further execution, when the parameter value is greater than 10.

Example

SASS TO CSS CONVERTER
@function myFunction($x){ @if $x > 10{ @error "$x value is too great"; } $result: $x * 2; @return $result; } footer ul{ font-size: myFunction(12) * 1px; }

Syntax

@error "error message";

Share this Page

Meet the Author