How to use the pretty-error function in pretty-error

To help you get started, we’ve selected a few pretty-error 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 Tencent / omi / packages / omi-ssr / src / server.js View on Github external
data.css = obj.css
    //const html = ReactDOM.renderToStaticMarkup();
    //const html = ReactDOM.renderToStaticMarkup(<div>);
    const resutl = Omi.renderToString()
    res.status(route.status || 200);

    res.send(`${resutl.html}`);
  } catch (err) {
    next(err);
  }
});

//
// Error handling
// -----------------------------------------------------------------------------
const pe = new PrettyError();
pe.skipNodeFiles();
pe.skipPackage('express');

// eslint-disable-next-line no-unused-vars
app.use((err, req, res, next) =&gt; {
  console.error(pe.render(err));
  res.status(err.status || 500);
  res.send(`${'error!'}`);
});

//
// Hot Module Replacement
// -----------------------------------------------------------------------------
if (module.hot) {
  app.hot = module.hot;
  //module.hot.accept();</div>
github jariz / gatsby-plugin-s3 / src / bin.ts View on Github external
import { Readable } from 'stream';
import { join, relative, resolve, sep } from 'path';
import { resolve as resolveUrl } from 'url';
import fs from 'fs';
import util from 'util';
import minimatch from 'minimatch';
import mime from 'mime';
import inquirer from 'inquirer';
import { config as awsConfig } from 'aws-sdk';
import { createHash } from 'crypto';
import isCI from 'is-ci';
import { getS3WebsiteDomainUrl, withoutLeadingSlash } from './util';
import { AsyncFunction, asyncify, parallelLimit } from 'async';

const cli: any = yargs();
const pe = new PrettyError();

const OBJECTS_TO_REMOVE_PER_REQUEST = 1000;

const promisifiedParallelLimit: (tasks: Array&gt;, limit: number) =&gt;
    // Have to cast this due to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20497
    // tslint:disable-next-line:no-any
    Promise = util.promisify(parallelLimit) as any;

const guessRegion = (s3: S3, constraint: void | string | undefined) =&gt; (
    constraint || s3.config.region || awsConfig.region
);

const getBucketInfo = async (config: PluginOptions, s3: S3): Promise&lt;{ exists: boolean, region?: string }&gt; =&gt; {
    try {
        const { $response } = await s3.getBucketLocation({ Bucket: config.bucketName }).promise();
github pubpub / pubpub / api / api.js View on Github external
mongoose.connect(process.env.mongoURI);
	}
	
}


// require('../server.babel'); // babel registration (runtime transpilation for node)

import express from 'express';
import session from 'express-session';
import bodyParser from 'body-parser';
import config from '../src/config';
import PrettyError from 'pretty-error';
import http from 'http';

const pretty = new PrettyError();
const app = express();
const server = new http.Server(app);

/*--------*/
// Configure app login, session, and passport settings
/*--------*/
const MongoStore = require('connect-mongo')(session);
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const User = require('./models').User;

passport.use(new LocalStrategy(
  function(username, password, done) {
	User.findOne({ username: username }, function(err, user) {
		if (err) { return done(err); }
		if (!user) {
github Wildhoney / Dory / server / helpers / github.js View on Github external
github.repos.getCommits(options, (error, response) => {

                redis.set(key, JSON.stringify(response));
                redis.expire(key, config.cacheExpiration);

                if (error) {
                    const response = JSON.parse(error.message);
                    const prettyError = new PrettyError();
                    console.log(prettyError.render(new Error(response.message)));
                    reject();
                    return;
                }

                resolve(response);

            });
github LiferayCloud / magnet / src / middleware / error.js View on Github external
return (err, req, res, next) => {
    const status = err.status || err.code || 500;
    const message = err.message || '';
    let result = {
      status,
      message,
    };
    if (err.errors) {
      result.errors = err.errors;
    }
    const renderedError = new PrettyError().render(err);
    const serializedError = JSON.stringify(result, 2, 2);
    log.error(false, `${renderedError}${serializedError}`);
    res.status(status).json(result);
  };
}
github commercetools / nodejs / packages / discount-code-exporter / src / cli.js View on Github external
const logError = error => {
  const errorFormatter = new PrettyError()

  if (npmlog.level === 'verbose')
    process.stderr.write(`ERR: ${errorFormatter.render(error)}`)
  else process.stderr.write(`ERR: ${error.message || error}`)
}
github commercetools / nodejs / packages / csv-parser-state / src / cli.js View on Github external
const logError = error => {
  const errorFormatter = new PrettyError()

  if (args.logLevel === 'debug')
    process.stderr.write(`ERR: ${errorFormatter.render(error)}`)
  else process.stderr.write(`ERR: ${error.message || error}`)
}

pretty-error

See nodejs errors with less clutter

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis