How to use the youch function in youch

To help you get started, we’ve selected a few youch 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 ludicrousxyz / light / src / utils / import-routes.ts View on Github external
handler: handler(async (req: IncomingMessage): Promise => {
        const youch = new Youch(err, req);
        const json = await youch.toJSON();
        console.log(forTerminal(json)); // eslint-disable-line
        return youch.toHTML();
      }),
      path: '*',
github ludicrousxyz / light / src / route.ts View on Github external
const youchPlugin = (fun: any): any => async (req: IM, res: SR): Promise => {
  try {
    return await fun(req, res);
  } catch (err) {
    const youch = new Youch(err, req);
    const json = await youch.toJSON();
    console.log(forTerminal(json)); // eslint-disable-line
    return youch.toHTML();
  }
};
github leohmoraes / rocketseat-02 / src / app.js View on Github external
this.server.use(async (err, req, res, next) => {
      if (process.env.NODE_ENV === 'development') {
        const errors = await new Youch(err, req).toJSON(); // toHTML();

        return res.status(500).json(errors);
      }

      return res.status(500).json({ error: 'Internal server error' });
    });
  }
github rodrigotamura / go-stack-2019 / module02 / src / app.js View on Github external
this.server.use(async (err, req, res, next) => {
      if (process.env.NODE_ENV === 'development') {
        const errors = await new Youch(err, req).toJSON();
        // you have an alternativo toHTML also
        // we prefer toJSON because in this case we are working over an API

        return res.status(500).json(errors);
      }

      return res.status(500).json({ error: 'Internal server error' });
    });
  }
github universal-vue / uvue / packages / @uvue / server / plugins / serverError.js View on Github external
async renderError(error, req) {
    if (process.env.NODE_ENV !== 'production') {
      const youch = new Youch(error, req);
      return youch.toHTML();
    } else {
      const { readFile } = require('fs-extra');
      return readFile(this.options.path, 'utf-8');
    }
  },
};
github osvaldokalvaitir / node-modulo3-novo / src / app.js View on Github external
this.server.use(async (err, req, res, next) => {
      if (process.env.NODE_ENV === 'development') {
        const errors = await new Youch(err, req).toJSON();

        return res.status(500).json(errors);
      }

      return res.status(500).json({ error: 'Internal server error' });
    });
  }

youch

HTML Pretty error stack viewer

MIT
Latest version published 6 months ago

Package Health Score

84 / 100
Full package analysis

Popular youch functions