Skip to content

Commit 509dad0

Browse files
committed
Add Feedback to Laravel example
1 parent f9bfb35 commit 509dad0

File tree

4 files changed

+99
-4
lines changed

4 files changed

+99
-4
lines changed

examples/laravel-4.2/app/routes.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,21 @@
1111
|
1212
*/
1313

14-
Route::get('/', function()
14+
function verifyCredentials()
1515
{
16+
Log::info('Verifying credentials');
17+
throw new Exception('No credentials passed!');
18+
}
19+
20+
21+
function authenticateUser()
22+
{
23+
Log::info('Authenticating the current user');
24+
verifyCredentials();
25+
}
26+
27+
28+
Route::get('/', function () {
1629
Log::info('Rendering a page thats about to error');
17-
throw new Exception('An unhandled exception');
30+
authenticateUser();
1831
});

examples/laravel-5.2/app/Exceptions/Handler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function report(Exception $e)
4848
*/
4949
public function render($request, Exception $e)
5050
{
51-
return parent::render($request, $e);
51+
// return parent::render($request, $e);
52+
return response()->view('errors.500', [
53+
'sentryID' => app('sentry')->getLastEventID(),
54+
], 500);
5255
}
5356
}

examples/laravel-5.2/app/Http/routes.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,21 @@
1111
|
1212
*/
1313

14+
function verifyCredentials()
15+
{
16+
Log::info('Verifying credentials');
17+
throw new Exception('No credentials passed!');
18+
}
19+
20+
21+
function authenticateUser()
22+
{
23+
Log::info('Authenticating the current user');
24+
verifyCredentials();
25+
}
26+
27+
1428
Route::get('/', function () {
1529
Log::info('Rendering a page thats about to error');
16-
throw new Exception('An unhandled exception');
30+
authenticateUser();
1731
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Internal Server Error</title>
5+
6+
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
7+
8+
<style>
9+
html, body {
10+
height: 100%;
11+
}
12+
13+
body {
14+
margin: 0;
15+
padding: 0;
16+
width: 100%;
17+
color: #B0BEC5;
18+
display: table;
19+
font-weight: 100;
20+
font-family: 'Lato';
21+
}
22+
23+
.container {
24+
text-align: center;
25+
display: table-cell;
26+
vertical-align: middle;
27+
}
28+
29+
.content {
30+
text-align: center;
31+
display: inline-block;
32+
}
33+
34+
.title {
35+
font-size: 72px;
36+
margin-bottom: 40px;
37+
}
38+
</style>
39+
</head>
40+
<body>
41+
<div class="container">
42+
<div class="content">
43+
<div class="title">Something went wrong.</div>
44+
@unless(empty($sentryID))
45+
<!-- Sentry JS SDK 2.1.+ required -->
46+
<script src="https://cdn.ravenjs.com/3.3.0/raven.min.js"></script>
47+
48+
<script>
49+
Raven.showReportDialog({
50+
eventId: '{{ $sentryID }}',
51+
52+
// use the public DSN (dont include your secret!)
53+
dsn: 'https://[email protected]/3235',
54+
55+
user: {
56+
'name': 'Jane Doe',
57+
'email': '[email protected]',
58+
}
59+
});
60+
</script>
61+
@endunless
62+
</div>
63+
</div>
64+
</body>
65+
</html>

0 commit comments

Comments
 (0)