Skip to content

Commit cba573f

Browse files
committed
Make sure uncaught exceptions are displayed before the script ends
1 parent 6899b8c commit cba573f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ function runCode($__source_code, $__bootstrap_file)
6060
if ($__bootstrap_file) {
6161
require $__bootstrap_file;
6262
}
63-
eval($__source_code);
63+
try {
64+
eval($__source_code);
65+
} catch (\Throwable $e) {
66+
echo '<br><br>Uncaught exception: '.get_class($e).' '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().'<br>';
67+
throw $e;
68+
}
6469
}
6570

6671
if (isset($_POST['code'])) {
@@ -209,4 +214,4 @@ function runCode($__source_code, $__bootstrap_file)
209214
</div>
210215
</div>
211216
</body>
212-
</html>
217+
</html>

0 commit comments

Comments
 (0)