|
45 | 45 | use framework\Loader;
|
46 | 46 | use framework\Dispatcher;
|
47 | 47 |
|
48 |
| -/* Set classes auto loader simply by instantiating framework Loader */ |
49 |
| -$loader = new Loader(); |
| 48 | +try { |
| 49 | + // Set classes autoloader simply by instantiating the framework Loader |
| 50 | + $loader = new Loader(); |
50 | 51 |
|
51 |
| -/* Create a dispatcher for handling URL request to the appropriate user controller */ |
52 |
| -$dispatcher = new Dispatcher(); |
53 |
| -$dispatcher->dispatch(); |
| 52 | + // Create a Dispatcher to dispatch URL request to the appropriate user controller |
| 53 | + $dispatcher = new Dispatcher(); |
| 54 | + $dispatcher->dispatch(); |
54 | 55 |
|
| 56 | +} catch (\Throwable $th) { |
| 57 | + |
| 58 | + //throw throwable; |
| 59 | + printCatch($th); |
| 60 | +} catch (Exception $e) { |
| 61 | + |
| 62 | + //throw exception; |
| 63 | + printCatch($e); |
| 64 | +} |
| 65 | + |
| 66 | +function printCatch($e) |
| 67 | +{ |
| 68 | + $html = <<<HTML |
| 69 | + <!doctype html> |
| 70 | + <html lang="en"> |
| 71 | + <head> |
| 72 | + <meta charset="utf-8"> |
| 73 | + <title>PHP Error</title> |
| 74 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 75 | + <!-- Bootstrap 5 CDN --> |
| 76 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> |
| 77 | + </head> |
| 78 | + <div class="container"> |
| 79 | + <body class="bg-white text-light"> |
| 80 | + <div class="container py-5"> |
| 81 | + <div class="alert bg-dark shadow-lg"> |
| 82 | + <h1 class="display-5 fw-bold text-danger"> |
| 83 | + <i class="bi bi-bug-fill"></i> Error! |
| 84 | + </h1> |
| 85 | + <hr class="border-light"> |
| 86 | + <p> |
| 87 | + <span class="badge bg-warning text-dark">File</span> |
| 88 | + <code class="h3">{$e->getFile()}</code> |
| 89 | + </p> |
| 90 | + <p> |
| 91 | + <span class="badge bg-info text-dark">Line</span> |
| 92 | + <code class="h2" >{$e->getLine()}</code> |
| 93 | + </p> |
| 94 | + <hr> |
| 95 | + <p class="lead text-light"> |
| 96 | + <span class="badge bg-danger text-dark">Error info</span><br> |
| 97 | + <code class="text-warning h2">{$e->getMessage()}</code> |
| 98 | + </p> |
| 99 | + <button class="btn btn-outline-light mt-3" onclick="location.reload()">🔁 Reload page</button> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + <div class="alert bg-dark shadow-lg"> |
| 103 | + <div class="text-center text-yellow bg-dark"> |
| 104 | + PHP WEB MVC Framework - [ |
| 105 | + <a href="https://github.com/rcarvello/webmvcframework/wiki">Wiki Pages</a> | |
| 106 | + <a href="https://github.com/rcarvello/webmvcframework">GitHub</a> ] |
| 107 | + </div> |
| 108 | + </body> |
| 109 | + </div> |
| 110 | + </html> |
| 111 | +HTML; |
| 112 | + echo $html; |
| 113 | +} |
55 | 114 |
|
0 commit comments