@charset "UTF-8";

// @description
// * err function.
// * This function accepts error message to toggle the output
// * when you are in testing or development environment.

// @access private

// @version 1.2.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace development-utils

// @module development-utils/toggle-error-message

// @dependencies:
// * - meta.type-of (SASS function).
// * - Config.$test-environment (config variable).
// * - Dev.err (function).

// @param {String} $message
// * The error message to be printed as expected value.
// * in two environment (testing or development).

// @throw {Exception}
// * Throws exceptions if the $test-environment variable is true.

// @example
// * If $test-environment variable is false.
// * .example {
// *   content: toggle-error-message("This is just an error message.");
// * }

// @output
// * .example {
// *   content: "ERROR: This is just an error message.";
// * }

// @return {String} - Returns the provided error message.

@use "sass:meta";
@use "../abstract/config" as Config;
@use "./error" as Dev;

@function toggle-error-message($error-msg) {
    @if meta.type-of($error-msg) != string {
        @error "Error message in toggle-error-message function must be in type string.";
    }

    @if Config.$test-environment == true {
        @return Dev.err($error-msg);
    } @else {
        @error $error-msg;
    }
}

@function throw($error-msg) {
    @return toggle-error-message($error-msg);
}
