Skip to content

Commit

Permalink
cleanup hmr error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 2, 2020
1 parent 6d8550b commit f2279c8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions snowpack/assets/hmr-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ socket.addEventListener('message', ({data: _data}) => {
return;
}
if (data.type === 'error') {
createNewErrorOverlay(data);
console.error(
`[ESM-HMR] ${data.fileLoc ? data.fileLoc + '\n' : ''}`,
data.title + '\n' + data.errorMessage,
);
createNewErrorOverlay(data);
return;
}
if (data.type === 'update') {
Expand All @@ -174,7 +174,13 @@ socket.addEventListener('message', ({data: _data}) => {
}
})
.catch((err) => {
console.error('update fail', err);
console.error('[ESM-HMR] Hot Update Error', err);
createNewErrorOverlay({
title: 'Hot Update Error',
fileLoc: data.url,
errorMessage: err.message,
errorStackTrace: err.stack,
});
});
return;
}
Expand All @@ -189,10 +195,11 @@ window.addEventListener('error', function (event) {
if (event.filename) {
fileLoc = event.filename;
if (event.lineno !== undefined) {
fileLoc += `:${event.lineno}`;
fileLoc += ` [:${event.lineno}`;
if (event.colno !== undefined) {
fileLoc += `:${event.colno}`;
}
fileLoc += `]`;
}
}
createNewErrorOverlay({
Expand Down

1 comment on commit f2279c8

@vercel
Copy link

@vercel vercel bot commented on f2279c8 Oct 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.