How to use pretty-error - 10 common examples

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 damncabbage / js-compiler-workshop / 07 Parser Combinators / index.js View on Github external
require('pretty-error').start().skipNodeFiles();
const { inspect } = require("util");
const stopHere = () => { console.log("\n\n... Stopping here."); process.exit(0); }


// We're going to use a Parser Combinator library called Eulalie.
const p = require("../support/eulalie");


// This is a parser. It's a value that represents the idea of
// "parsing a string that starts with 'traffic light'":
const trafficLight =
  p.string("traffic light");

// This, too, is a parser. It represents "parsing a string that
// starts with 'The', a space, and then 'traffic light'".
// It is a parser itself: it's made up of other parsers, built
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 eden-js / cli / lib / eden.js View on Github external
error (e) {
    // log error
    console.log (error.render (e));

    // emit error
    this.emit ('eden:error', e);
  }
github eden-js / cli / lib / eden.js View on Github external
process.on ('unhandledRejection', (e) => {
  // log error
  console.log (error.render (e));
});
process.on ('uncaughtException', (e) => {
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 damncabbage / js-compiler-workshop / 03 Expressive Parsing / index.js View on Github external
require('pretty-error').start().skipNodeFiles();
const { inspect } = require("util");


////////////////////////
//                    //
//     Tokenizer      //
//                    //
////////////////////////

function stringToTokens(input) {
  // Define the shape of tokens to look for.
  // We're using regexps for this because they're good/quick for simple
  // tokenizers; this isn't how all compilers are written. :'D
  const tokenizerRules = [
    {
      regex: /\(/,
github damncabbage / js-compiler-workshop / 08 FP Parsing / index.js View on Github external
require('pretty-error').start().skipNodeFiles();
const { inspect } = require("util");

// Let's pull in Eulalie for the tokeniser.
const p = require("../support/eulalie");


////////////////////////
//                    //
//     Tokenizer      //
//                    //
////////////////////////

function stringToTokens(input) {

  const ignoreResult = parser => p.seq(function*(){
    yield parser;
github damncabbage / js-compiler-workshop / 02 Basic Parsing / index.js View on Github external
require('pretty-error').start().skipNodeFiles();
const { inspect } = require("util");


////////////////////////
//                    //
//     Tokenizer      //
//                    //
////////////////////////

function stringToTokens(input) {
  // Define the shape of tokens to look for.
  // We're using regexps for this because they're good/quick for simple
  // tokenizers; this isn't how all compilers are written. :'D
  const tokenizerRules = [
    {
      regex: /\(/,
github damncabbage / js-compiler-workshop / 06 Let It Be / solution.js View on Github external
require('pretty-error').start().skipNodeFiles();
const { inspect } = require("util");


////////////////////////
//                    //
//     Tokenizer      //
//                    //
////////////////////////

function stringToTokens(input) {
  const tokenizerRules = [
    {
      regex: /let\b/,
      token: "letKeyword"
    },
    {

pretty-error

See nodejs errors with less clutter

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis