Skip to main content

variable-type ()

Returns an error message stating a variable received the wrong type.

Parameters

$name
The name of the variable which has received the wrong type.
Type
String
$value
The value which was received.
Type
*
$types
The types which are expected.
Type
ArgList<*>
$message
The additional message which describes the issue. Must be passed by name.
Type
String
Default
null

Return Value

String
A string describing what types are acceptable for a variable and the value that is misconfigured.

Example

@use '@sass-fairy/exception';

$height: 20rem !default;

@if meta.type-of($height) != 'number' {
@error exception.variable-type('height', $height, 'number');
}

@if $height < 0 {
@error exception.variable('Value must not be less than zero, but is `#{$height}`', 'height');
}