How to use the @parcel/logger.formatError function in @parcel/logger

To help you get started, we’ve selected a few @parcel/logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parcel-bundler / parcel / packages / core / parcel-bundler / src / HMRServer.js View on Github external
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);
  }
github parcel-bundler / parcel / packages / core / parcel-bundler / src / Server.js View on Github external
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(''),
      );
    }