Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
73303a71
Unverified
Commit
73303a71
authored
Jul 30, 2020
by
Luis Alvarez D
Committed by
GitHub
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Examples] Fix with-sentry (#15694)
parent
dcb69ee9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
3 deletions
+1
-3
_error.js
examples/with-sentry/pages/_error.js
+1
-3
No files found.
examples/with-sentry/pages/_error.js
View file @
73303a71
import
NextErrorComponent
from
'next/error'
import
NextErrorComponent
from
'next/error'
import
*
as
Sentry
from
'@sentry/node'
import
*
as
Sentry
from
'@sentry/node'
const
MyError
=
async
({
statusCode
,
hasGetInitialPropsRun
,
err
})
=>
{
const
MyError
=
({
statusCode
,
hasGetInitialPropsRun
,
err
})
=>
{
if
(
!
hasGetInitialPropsRun
&&
err
)
{
if
(
!
hasGetInitialPropsRun
&&
err
)
{
// getInitialProps is not called in case of
// getInitialProps is not called in case of
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
// err via _app.js so it can be captured
Sentry
.
captureException
(
err
)
Sentry
.
captureException
(
err
)
// flush is needed after calling captureException to send server side errors to Sentry, otherwise the serverless function will exit before it's sent
await
Sentry
.
flush
(
2000
)
}
}
return
<
NextErrorComponent
statusCode
=
{
statusCode
}
/
>
return
<
NextErrorComponent
statusCode
=
{
statusCode
}
/
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment