mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
11816537c3
This PR adds links to the [react-error-overlay](https://www.npmjs.com/package/react-error-overlay). This allows a developer to open a stack trace in its own editor. ![codelinking](https://user-images.githubusercontent.com/1265681/44278860-a63e0a80-a24f-11e8-9c69-c5365c026c58.gif) Closes #4813
15 lines
479 B
JavaScript
15 lines
479 B
JavaScript
import url from 'url'
|
|
import launchEditor from 'launch-editor'
|
|
|
|
export default function errorOverlayMiddleware (req, res, next) {
|
|
if (req.url.startsWith('/_next/development/open-stack-frame-in-editor')) {
|
|
const query = url.parse(req.url, true).query
|
|
const lineNumber = parseInt(query.lineNumber, 10) || 1
|
|
const colNumber = parseInt(query.colNumber, 10) || 1
|
|
launchEditor(`${query.fileName}:${lineNumber}:${colNumber}`)
|
|
res.end()
|
|
} else {
|
|
next()
|
|
}
|
|
}
|