Skip to content

Commit bc2d5f3

Browse files
authored
Show errored file always in the error overlay. (vercel#1470)
This was not happening when there's module not found errors. Now we try to do this for all the errors if possible.
1 parent d6b8a53 commit bc2d5f3

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/error-debug.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ export default ({ error, error: { name, message, module } }) => (
1010
{module ? <div style={styles.heading}>Error in {module.rawRequest}</div> : null}
1111
{
1212
name === 'ModuleBuildError'
13-
? <pre style={styles.message} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
13+
? <pre style={styles.stack} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
1414
: <StackTrace error={error} />
1515
}
1616
</div>
1717
)
1818

1919
const StackTrace = ({ error: { name, message, stack } }) => (
2020
<div>
21-
<div style={styles.heading}>{name && message && `${name}: ${message}`}</div>
22-
<pre style={styles.message}>
21+
<div style={styles.heading}>{message || name}</div>
22+
<pre style={styles.stack}>
2323
{stack}
2424
</pre>
2525
</div>
@@ -39,21 +39,22 @@ const styles = {
3939
zIndex: 9999
4040
},
4141

42-
message: {
42+
stack: {
4343
fontFamily: '"SF Mono", "Roboto Mono", "Fira Mono", consolas, menlo-regular, monospace',
4444
fontSize: '13px',
4545
color: '#fbe7f1',
4646
margin: 0,
4747
whiteSpace: 'pre-wrap',
48-
wordWrap: 'break-word'
48+
wordWrap: 'break-word',
49+
marginTop: '20px'
4950
},
5051

5152
heading: {
5253
fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
5354
fontSize: '15px',
5455
fontWeight: 'bold',
55-
color: '#ff84bf',
56-
marginBottom: '20px'
56+
color: '#febfdd',
57+
marginBottom: '5px'
5758
}
5859
}
5960

server/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ function errorToJSON (err) {
142142
const { name, message, stack } = err
143143
const json = { name, message, stack }
144144

145-
if (name === 'ModuleBuildError') {
146-
// webpack compilation error
147-
const { module: { rawRequest } } = err
145+
if (err.module) {
146+
// rawRequest contains the filename of the module which has the error.
147+
const { rawRequest } = err.module
148148
json.module = { rawRequest }
149149
}
150150

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy