nicer exception handling
[pharext/pharext.org] / public / index.php
1 <?php
2
3 namespace app;
4
5 try {
6 $bootstrap = require "../app/bootstrap.php";
7 $injector = $bootstrap(["config", "github", "plates", "model", "web"]);
8 return $injector->execute(Web::class);
9 } catch (\Exception $e) {
10 $error = $e->getMessage();
11 $stack = $e->getTraceAsString();
12 @header("X-Exception: ".get_class($e), false, 500);
13 Web::cleanBuffers();
14 }
15 ?>
16 <html>
17 <head>
18 <meta charset="utf-8">
19 <title>Application Error</title>
20 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
21 </head>
22 <body>
23 <div class="container">
24 <div class="jumbotron">
25 <h1>Application Error</h1>
26 <h2>Aww, you really gotta do that?!</h2>
27 <p class="text-danger">
28 <strong><?= htmlspecialchars($error) ?></strong>
29 </p>
30 <p>
31 Sorry, anyway.
32 </p>
33 </div>
34 <?php if (APP_ENVIRONMENT != "production") : ?>
35 <pre><?= htmlspecialchars($stack) ?></pre>
36 <?php endif; ?>
37 </div>
38 </body>
39 </html>