Skip to content

Commit

Permalink
Remove un-helpful error in with-sentry example (#36902)
Browse files Browse the repository at this point in the history
The error reported here is unclear and un-helpful so we shouldn't be recommending to report this by default. 

x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1652466540356879) 

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
  • Loading branch information
ijjk committed May 13, 2022
1 parent b122178 commit 167a91b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions examples/with-sentry/pages/_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
return <NextErrorComponent statusCode={statusCode} />
}

MyError.getInitialProps = async ({ res, err, asPath }) => {
MyError.getInitialProps = async ({ res, err }) => {
const errorInitialProps = await NextErrorComponent.getInitialProps({
res,
err,
Expand Down Expand Up @@ -48,13 +48,8 @@ MyError.getInitialProps = async ({ res, err, asPath }) => {
}

// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Sentry
Sentry.captureException(
new Error(`_error.js getInitialProps missing data at path: ${asPath}`)
)
await Sentry.flush(2000)

// information about what the error might be. This can be caused by
// a falsy value being thrown e.g. throw undefined
return errorInitialProps
}

Expand Down

0 comments on commit 167a91b

Please sign in to comment.