1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Show errored file always in the error overlay. (#1470)

This was not happening when there's module not found errors.
Now we try to do this for all the errors if possible.
This commit is contained in:
Arunoda Susiripala 2017-03-23 04:43:23 +05:30 committed by GitHub
parent d6b8a530ed
commit bc2d5f3bdb
2 changed files with 11 additions and 10 deletions

View file

@ -10,7 +10,7 @@ export default ({ error, error: { name, message, module } }) => (
{module ? <div style={styles.heading}>Error in {module.rawRequest}</div> : null} {module ? <div style={styles.heading}>Error in {module.rawRequest}</div> : null}
{ {
name === 'ModuleBuildError' name === 'ModuleBuildError'
? <pre style={styles.message} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} /> ? <pre style={styles.stack} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
: <StackTrace error={error} /> : <StackTrace error={error} />
} }
</div> </div>
@ -18,8 +18,8 @@ export default ({ error, error: { name, message, module } }) => (
const StackTrace = ({ error: { name, message, stack } }) => ( const StackTrace = ({ error: { name, message, stack } }) => (
<div> <div>
<div style={styles.heading}>{name && message && `${name}: ${message}`}</div> <div style={styles.heading}>{message || name}</div>
<pre style={styles.message}> <pre style={styles.stack}>
{stack} {stack}
</pre> </pre>
</div> </div>
@ -39,21 +39,22 @@ const styles = {
zIndex: 9999 zIndex: 9999
}, },
message: { stack: {
fontFamily: '"SF Mono", "Roboto Mono", "Fira Mono", consolas, menlo-regular, monospace', fontFamily: '"SF Mono", "Roboto Mono", "Fira Mono", consolas, menlo-regular, monospace',
fontSize: '13px', fontSize: '13px',
color: '#fbe7f1', color: '#fbe7f1',
margin: 0, margin: 0,
whiteSpace: 'pre-wrap', whiteSpace: 'pre-wrap',
wordWrap: 'break-word' wordWrap: 'break-word',
marginTop: '20px'
}, },
heading: { heading: {
fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif', fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
fontSize: '15px', fontSize: '15px',
fontWeight: 'bold', fontWeight: 'bold',
color: '#ff84bf', color: '#febfdd',
marginBottom: '20px' marginBottom: '5px'
} }
} }

View file

@ -142,9 +142,9 @@ function errorToJSON (err) {
const { name, message, stack } = err const { name, message, stack } = err
const json = { name, message, stack } const json = { name, message, stack }
if (name === 'ModuleBuildError') { if (err.module) {
// webpack compilation error // rawRequest contains the filename of the module which has the error.
const { module: { rawRequest } } = err const { rawRequest } = err.module
json.module = { rawRequest } json.module = { rawRequest }
} }