Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emitError(err) {
let {message, stack} = logger.formatError(err);
// store the most recent error so we can notify new connections
// and so we can broadcast when the error is resolved
this.unresolvedError = {
type: 'error',
error: {
message,
stack,
},
};
this.broadcast(this.unresolvedError);
}
function send500(error) {
setHeaders(res);
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.writeHead(500);
let errorMesssge = '<h1>🚨 Build Error</h1>';
if (process.env.NODE_ENV === 'production') {
errorMesssge += '<p><b>Check the console for details.</b></p>';
} else {
const {message, stack} = logger.formatError(error, {color: true});
errorMesssge += `<p><b>${message}</b></p>`;
if (stack) {
errorMesssge += `<div style="background: black; padding: 1rem;">${ansiToHtml.toHtml(
stack,
)}</div>`;
}
}
res.end(
[
``,
`<title>🚨 Build Error</title>`,
`${errorMesssge}`,
].join(''),
);
}