Skip to content

Commit 25e26f9

Browse files
committed
Add exception handling notes
1 parent 5db370f commit 25e26f9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,26 @@ your custom feature using the `addFeature` method:
331331

332332
* `addFeature($name)` registers the `$name`.
333333

334+
### Exception Handling
335+
336+
If your web appilcation compiles SCSS on-the-fly, you need to handle any potential
337+
exceptions thrown by the Compiler. This is especially important in a production
338+
environment where the content may be untrusted (e.g., user uploaded) because
339+
the exception stack trace may contain sensitive data.
340+
341+
{% highlight php startinline=true %}
342+
use Leafo\ScssPhp\Compiler;
343+
344+
try {
345+
$scss = new Compiler();
346+
347+
echo $scss->compile($content);
348+
} catch (\Exception $e) {
349+
echo '';
350+
syslog(LOG_ERR, 'scssphp: Unable to compile content');
351+
}
352+
{% endhighlight %}
353+
334354
## SCSS Server
335355

336356
The SCSS server is a small class that helps with automatically compiling SCSS.

0 commit comments

Comments
 (0)