Skip to content

Commit 638c3a7

Browse files
committed
Handle error
1 parent 96d0d7c commit 638c3a7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/index.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@
1111

1212
$vars = eval('return ' . $_POST['vars'] . ';');
1313

14-
echo $pug->render($_POST['pug'], $vars);
14+
try {
15+
echo $pug->render($_POST['pug'], $vars);
16+
} catch (\Exception $e) {
17+
$message = trim($e->getMessage());
18+
echo 'Error' . (substr($message, 0, 1) === '('
19+
? preg_replace('/^\((\d+)\)(\s*:)?/', ' line $1:', $message)
20+
: ': ' . $message
21+
);
22+
}

0 commit comments

Comments
 (0)