Aliases
functions
se-init (alias for sass-errors-init)
@function se-init() { ... }Refer to sass-errors-init.
se-store (alias for sass-errors-store)
@function se-store() { ... }Refer to sass-errors-store.
se-message (alias for sass-errors-message)
@function se-message() { ... }Refer to sass-errors-message.
se-new (alias for sass-errors-new)
@function se-new() { ... }Refer to sass-errors-new.
se-throw (alias for sass-errors-throw)
@function se-throw() { ... }Refer to sass-errors-throw.
se-try (alias for sass-errors-try)
@function se-try() { ... }Refer to sass-errors-try.
se-catch (alias for sass-errors-catch)
@function se-catch() { ... }Refer to sass-errors-catch.
se-try-catch (alias for sass-errors-try-catch)
@function se-try-catch() { ... }Refer to sass-errors-try-catch.
se-get (alias for sass-errors-get)
@function se-get() { ... }Refer to sass-errors-get.
se-is-exception (alias for sass-errors-is-exception)
@function se-is-exception() { ... }Refer to sass-errors-is-exception.
se-debug (alias for sass-errors-debug)
@function se-debug() { ... }Refer to sass-errors-debug.
se-error (alias for sass-errors-error)
@function se-error() { ... }Refer to sass-errors-error.
se-warn (alias for sass-errors-warn)
@function se-warn() { ... }Refer to sass-errors-warn.
API
functions
sass-errors-catch (aliased as se-catch )
@function sass-errors-catch($types...) { ... }Description
If an Exception has been throw, catch it and return it. The Exception will not be catched again.
If types $types are given, return the Exception only if its type matches with one of the given types. Otherwise, return null.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$types... | Type or types the Exception type must match to. | String | —none |
Returns
Exception or Null —Catched Exception.
Example
Catch an Exception
@function my-function-with-exception() {
@return sass-errors-throw('Error', 'my_error_type');
}
$ret: my-function-with-exception();
$e: sass-errors-catch();
// 'my_error_type' ExceptionTry to catch several times the same Exception
$ret: my-function-with-exception();
$e: sass-errors-catch();
// 'my_error_type' Exception
$e: sass-errors-catch();
// nullCatch specific types of Exceptions (with a type matching)
$ret: my-function-with-exception();
$e: sass-errors-catch('a_type', 'my_error_type');
// 'my_error_type' ExceptionCatch specific types of Exceptions (with no types matching)
$ret: my-function-with-exception();
$e: sass-errors-catch('a_type', 'an_other_type');
// nullUsed by
- [function]
se-catch - [function]
sass-errors-try-catch
See
- [function]
sass-errors-throw
sass-errors-get (aliased as se-get )
@function sass-errors-get() { ... }Description
Returns current thrown and not catched Exception. If not Exception has been thrown or is not already catchen, returns null
Parameters
None.
Returns
Exception or Null —Current thrown and not catched Exception.
Example
Get an Exception
@function my-function-with-exception() {
@return sass-errors-throw('Error', 'my_error_type');
}
$ret: my-function-with-exception();
$e: sass-errors-get();
// 'my_error_type' ExceptionGet several times the same Exception
$ret: my-function-with-exception();
$e: sass-errors-get();
// 'my_error_type' Exception
$e: sass-errors-get();
// 'my_error_type' ExceptionGet an Exception after it has been catched
$ret: my-function-with-exception();
$e: sass-errors-catch();
// 'my_error_type' Exception
$e: sass-errors-get();
// nullUsed by
- [function]
se-get
sass-errors-init (aliased as se-init )
@function sass-errors-init($prefix: null) { ... }Description
Initialize Sass Errors required variables and options
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$prefix | Default prefix for new Exceptions | String | null |
Example
$_: sass-errors-init();Used by
- [function]
se-init
sass-errors-is-exception (aliased as se-is-exception )
@function sass-errors-is-exception() { ... }Description
Returns true if an Exception has been thrown and not catched, false otherwise.
Parameters
None.
Returns
BooleanExample
Check if an Exception exists
@function my-function-with-exception() {
@return sass-errors-throw('Error', 'my_error_type');
}
$is_e: sass-errors-is-exception();
// `false`
$ret: my-function-with-exception();
$is_e: sass-errors-is-exception();
// `true`
$e: sass-errors-catch();
$is_e: sass-errors-is-exception();
// `false`Used by
- [function]
se-is-exception
sass-errors-message (aliased as se-message )
@function sass-errors-message($error, $prefix: null) { ... }Description
Makes a formatted message from an error message and a prefix and returns it.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$error | Error message | String | —none |
$prefix | Message prefix | String | null |
Returns
StringExample
Simple message
$msg: sass-errors-message('Error');
// 'Error'Message with prefix
$msg: sass-errors-message('Error', 'my-function');
// 'my-function: Error'Used by
- [function]
se-message - [function]
sass-errors-new
sass-errors-new (aliased as se-new )
@function sass-errors-new($error, $type, $datas: (), $prefix: $-sass-errors-prefix) { ... }Description
Creates an Exception object and returns it. If an Exception is passed as first argument, returns it.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$error | Error message | String | —none |
$type | Exception type | String | —none |
$datas | Map of relevant datas to be embedded in the Exception | Map | () |
$prefix | Message prefix, global prefix by default (see | String | $-sass-errors-prefix |
Returns
ExceptionExample
@function my-function($value) {
$e: sass-errors-new('Error', 'unknown_error', (value: $value), 'my-function');
// (
// message: 'my-function: Error',
// error: 'Error',
// type: 'unknown_error',
// datas: (value: ...),
// )
}Requires
- [function]
sass-errors-message
Used by
- [function]
se-new - [function]
sass-errors-store - [function]
sass-errors-throw
sass-errors-store (aliased as se-store )
@function sass-errors-store($obj, $args...: ()...) { ... }Description
Create an Exception, append it to the given store $obj and return it. The new exception is not thrown. If an Exception is passed as second argument, store it.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$obj | List where to store the new Exception | List | —none |
$args... | Arguments used to create an Exception. See | Arglist | () |
Returns
List —The new list
Example
$store: ();
$store: sass-errors-new($store, 'Error 1', 'unknown_error');
$store: sass-errors-new($store, 'Error 2', 'unknown_error');
// (
// (
// message: 'Error 1',
// error: 'Error 1,
// type: 'unknown_error',
// datas: ()
// ),
// (
// message: 'Error 2',
// error: 'Error 1,
// type: 'unknown_error',
// datas: ()
// )
// )Requires
- [function]
sass-errors-new
Used by
- [function]
se-store
See
- [function]
sass-errors-new
sass-errors-throw (aliased as se-throw )
@function sass-errors-throw($args...: ()...) { ... }Description
Create an Exception and throw it. If an Exception is passed as first parameter, throw it. Always return false: this function should be called with @return.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$args... | Arguments used to create an Exception. See | Arglist | () |
Returns
FalseExample
@function my-function() {
@return sass-errors-throw('Error', 'unknown_error');
}Requires
- [function]
sass-errors-new
Used by
- [function]
se-throw - [function]
sass-errors-try
See
- [function]
sass-errors-new
sass-errors-try-catch (aliased as se-try-catch )
@function sass-errors-try-catch($value, $catch_func_name: sass-errors-error, $catch_func_args: ()..., $args...: ()...) { ... }Description
If the passed value $value is equal to false and no exception has been thrown, throw a new unknown_error Exception.
If an Exception has been thrown, catch it with sass-errors-catch and pass the Exception to the given Exception Handler $handler with its arguments $handler_args. The $handler function must be defined in the same scope as sass-errors-try-catch.
If an Exception has been thrown, returns false. Otherwise, returns$value`.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$value | Value to check. | Any | —none |
$catch_func_name | Name of the function to which the Exception is passed. | String | sass-errors-error |
$catch_func_args | Arguments of the catch function, following the Exception. | Arglist | () |
$args... | Arguments used to create an Exception. See | Arglist | () |
Returns
* or False —The function return.
Example
@function my-try-function-with-value() {
@return 'simple_value';
}
@function my-try-function-with-exception() {
@return sass-errors-throw('Error', 'my_error_type');
}
@function my-catch-function($e) {
@debug $e;
}
$ret: sass-errors-try-catch(my-try-function-with-value(), my-catch-function, ());
// 'simple value'
$ret: sass-errors-try-catch(my-try-function-with-exception(), my-catch-function, ());
// $ret: `false`
// @debug: 'my_error_type' ExceptionRequires
- [function]
sass-errors-try - [function]
sass-errors-catch
Used by
- [function]
se-try-catch
See
- [function]
sass-errors-try - [function]
sass-errors-catch
sass-errors-try (aliased as se-try )
@function sass-errors-try($value, $args...: ()...) { ... }Description
If the passed value $value is equal to false and no exception has been thrown, throw a new unknown_error Exception. If an Exception has been thrown, returns false. Otherwise, returns$value.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$value | Value to check. | Any | —none |
$args... | Arguments used to create an Exception. See | Arglist | () |
Returns
* or False —The given value, or false if an exception has been thrown.
Example
A non-false value is returned
@function my-function-with-value() {
@return 'simple_value';
}
$ret: sass-errors-try(my-function-with-value());
// 'simple value'
$e: sass-errors-catch();
// nullfalse is returned
@function my-function-with-false() {
@return false;
}
$ret: sass-errors-try(my-function-with-false());
// false
$e: sass-errors-catch();
// 'unknown_error' ExceptionSetting the Exception to be throw when false is returned
@function my-function-with-false() {
@return false;
}
$ret: sass-errors-try(
my-function-with-false(),
'My function failed',
'my_function_failed'
);
// false
$e: sass-errors-catch();
// 'my_function_failed' ExceptionAn Exception is thrown
@function my-function-with-exception() {
@return sass-errors-throw('Error', 'my_error_type');
}
$ret: sass-errors-try(my-function-with-exception());
// false
$e: sass-errors-catch();
// 'my_error_type' ExceptionRequires
- [function]
sass-errors-throw
Used by
- [function]
se-try - [function]
sass-errors-try-catch
Exception Handlers
functions
sass-errors-debug (aliased as se-debug )
@function sass-errors-debug($e) { ... }Description
Display the message of the given Exception $e with @debug. This function is an Exception Handler and can be passed as a catch function to sass-errors-try-catch.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$e | —none | Exception | —none |
Example
$e: sass-errors-throw('Error', $prefix: 'my-function');
$_: sass-errors-debug($e);
// @debug: 'my-function: Error'Used by
- [function]
se-debug
See
- [function]
sass-errors-try-catch
sass-errors-error (aliased as se-error )
@function sass-errors-error($e) { ... }Description
Display the message of the given Exception $e with @error. This function is an Exception Handler and can be passed as a catch function to sass-errors-try-catch.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$e | —none | Exception | —none |
Example
$e: sass-errors-throw('Error', $prefix: 'my-function');
$_: sass-errors-error($e);
// @error: 'my-function: Error'Used by
- [function]
se-error
See
- [function]
sass-errors-try-catch
sass-errors-warn (aliased as se-warn )
@function sass-errors-warn($e) { ... }Description
Display the message of the given Exception $e with @warn. This function is an Exception Handler and can be passed as a catch function to sass-errors-try-catch.
Parameters
| parameterName | parameterDescription | parameterType | parameterDefault value |
|---|---|---|---|
$e | —none | Exception | —none |
Example
$e: sass-errors-throw('Error', $prefix: 'my-function');
$_: sass-errors-debug($e);
// @warn: 'my-function: Error'Used by
- [function]
se-warn
See
- [function]
sass-errors-try-catch