Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/3rdparty.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scssphp/scssphp/src/Exception/SassScriptException.php')
-rw-r--r--scssphp/scssphp/src/Exception/SassScriptException.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/scssphp/scssphp/src/Exception/SassScriptException.php b/scssphp/scssphp/src/Exception/SassScriptException.php
new file mode 100644
index 00000000..19356a7a
--- /dev/null
+++ b/scssphp/scssphp/src/Exception/SassScriptException.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace ScssPhp\ScssPhp\Exception;
+
+/**
+ * An exception thrown by SassScript.
+ *
+ * This class does not implement SassException on purpose, as it should
+ * never be returned to the outside code. The compilation will catch it
+ * and replace it with a SassException reporting the location of the
+ * error.
+ */
+class SassScriptException extends \Exception
+{
+ /**
+ * Creates a SassScriptException with support for an argument name.
+ *
+ * This helper ensures a consistent handling of argument names in the
+ * error message, without duplicating it.
+ *
+ * @param string $message
+ * @param string|null $name The argument name, without $
+ *
+ * @return SassScriptException
+ */
+ public static function forArgument($message, $name = null)
+ {
+ $varDisplay = !\is_null($name) ? "\${$name}: " : '';
+
+ return new self($varDisplay . $message);
+ }
+}