Catch known errors and prettify them instead of showing the
    entire traceback, for better UX
760676
def prettify_exc(error):
    """"""
    matched_exceptions = [k for k in KNOWN_EXCEPTIONS.keys() if k in error]
    if not matched_exceptions:
        return "{}".format(vistir.misc.decode_for_output(error))
    errors = []
    for match in matched_exceptions:
        _, error, info = error.rpartition(KNOWN_EXCEPTIONS[match])
        errors.append("{} {}".format(error, info))

    return "\n".join(errors)
550911
function formatError(e) {
    if (!e.err) {
        return e.message
    }
    // PluginError
    if (typeof e.err.showStack === 'boolean') {
        return e.err.toString()
    }
    // Normal error
    if (e.err.stack) {
        return e.err.stack
    }
    // Unknown (string, number, etc.)
    return new Error(String(e.err)).stack
}
1173957
def print_traceback(with_colors=True):
    
    #traceback.print_tb()
    import traceback
    stack = traceback.extract_stack()
    stack_lines = traceback.format_list(stack)
    tbtext = ''.join(stack_lines)
    if with_colors:
        try:
            from pygments import highlight
            from pygments.lexers import get_lexer_by_name
            from pygments.formatters import TerminalFormatter
            lexer = get_lexer_by_name('pytb', stripall=True)
            formatter = TerminalFormatter(bg='dark')
            formatted_text = highlight(tbtext, lexer, formatter)
            print(formatted_text)
        except Exception:
            print(tbtext)
    else:
        print(tbtext)
555533
function formatRequestErrors(request, errors) {
  const CONTEXT_BEFORE = 20;
  const CONTEXT_LENGTH = 60;

  const queryLines = request.getQueryString().split('\n');
  return errors.map(({locations = [], message}, ii) => {
    const prefix = (ii + 1) + '. ';
    const indent = ' '.repeat(prefix.length);
    return (
      prefix + message + '\n' +
      locations.map(({column, line}) => {
        const queryLine = queryLines[line - 1];
        const offset = Math.min(column - 1, CONTEXT_BEFORE);
        return [
          queryLine.substr(column - 1 - offset, CONTEXT_LENGTH),
          ' '.repeat(offset) + '^^^',
        ].map(messageLine => indent + messageLine).join('\n');
      }).join('\n')
    );
  }).join('\n');
}
62411
function callback(err, hasError) {

    if (err !== null) {
        console.log(chalk.red('Error running JSHint over project: %j\n'), err);
    }

    if (hasError) {
        console.log(chalk.blue('\nSummary\n=======\n'));
        for (var errorCode in errors) {
            if (errors.hasOwnProperty(errorCode)) {
                displaySummary(errorCode);
            }
        }

        console.log('');

        if (totalErrors > 1) {
            console.log(chalk.red('Found %d errors.\n'), totalErrors);
        } else {
            console.log(chalk.red('Found 1 error.\n'));
        }
    } else {
        console.log(chalk.green('No JSHint errors found.\n'));
    }
}
1327039
def render_report_error(self, request, error, status):
        

        opts = self.model._meta
        app_label = opts.app_label
        request.current_app = self.admin_site.name
        context = dict(
            self.admin_site.each_context(request),
            module_name=force_text(opts.verbose_name_plural),
            title=(_('Tracking report error for %s') % force_text(opts.verbose_name)),
            opts=opts, app_label=app_label, error=error
        )

        return TemplateResponse(request, self.report_error_template or [
            "admin/{}/{}/tracking_report_error.html".format(app_label, opts.model_name),
            "admin/{}/tracking_report_error.html".format(app_label),
            "admin/tracking_report_error.html"
        ], context, status=status)
1363051
def error_output(self, message, method_affected=None):
        
        color_fn = self._py3_wrapper.get_config_attribute
        color = color_fn(self.module_full_name, "color_error")
        if hasattr(color, "none_setting"):
            color = color_fn(self.module_full_name, "color_bad")
        if hasattr(color, "none_setting"):
            color = None

        error = {
            "full_text": message,
            "color": color,
            "instance": self.module_inst,
            "name": self.module_name,
        }
        for method in self.methods.values():
            if method_affected and method["method"] != method_affected:
                continue

            method["last_output"] = [error]

        self.allow_config_clicks = False
        self.set_updated()
784479
function(error) {
  return util.format('  %s: %s',
    chalk.magenta(error.plugin.name),
    error.message);
}
601588
def _surpress_formatting_errors(fn):
    
    @wraps(fn)
    def inner(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except ValueError:
            return ""
    return inner
1164533
function formatError(err, options) {
    options = options || {};
    var name = err.name || err.constructor.name;
    var str = util.format('%s: %s\n', name, err.message);
    if (err.buffer && err.buffer.hexdump) {
        str += err.buffer.hexdump({
            colored: options.color,
            boldStart: false,
            highlight: options.color ? errorHighlighter(err, options) : null
        });
    } else if (Buffer.isBuffer(err.buffer)) {
        if (options.color) {
            str += formatBufferColored(err, options);
        } else {
            str += formatBufferUncolored(err, options);
        }
    }
    return str;
}
497865
def display_error_message(ex)
      trace "#{name} aborted!"
      trace ex.message
      if options.backtrace
        trace ex.backtrace.join("\n")
      else
        trace Backtrace.collapse(ex.backtrace).join("\n")
      end
      trace "Tasks: #{ex.chain}" if has_chain?(ex)
      trace "(See full trace by running task with --trace)" unless
        options.backtrace
    end
1122043
def _print_errs(self):
        
        i = 0
        for error in self.errors:
            print(self._errmsg(error, tb=True, i=i))
            # for spacing
            if self.errs_traceback is False:
                print()
            i += 1
1070746
def pretty_errors(fn):
    

    @wraps(fn)
    def pretty_errors_wrapper(*args, **kwargs):
        try:
            fn(*args, **kwargs)
        except (OneCodexException, UploadException) as e:
            sys.stderr.write("\nERROR: {}".format(e))
            sys.stderr.write("\nPlease feel free to contact us for help at help@onecodex.com\n\n")
            sys.exit(1)

    return pretty_errors_wrapper
426632
def ErrorMsg():
    
    import traceback

    limit = None
    _type, value, tb = sys.exc_info()
    _list = traceback.format_tb(tb, limit) + \
        traceback.format_exception_only(_type, value)
    return "Traceback (innermost last):\n" + "%-20s %s" % (
        " ".join(_list[:-1]),
        _list[-1])
615558
def prepare_for_reraise(error, exc_info=None):
    
    if not hasattr(error, "_type_"):
        if exc_info is None:
            exc_info = sys.exc_info()
        error._type_ = exc_info[0]
        error._traceback = exc_info[2]
    return error
1106662
def render_error_debug(request, exception, is_html):
    '''
    '''
    error = Html('div', cn='well well-lg') if is_html else []
    for trace in format_traceback(exception):
        counter = 0
        for line in trace.split('\n'):
            if line.startswith('  '):
                counter += 1
                line = line[2:]
            if line:
                if is_html:
                    line = Html('p', escape(line), cn='text-danger')
                    if counter:
                        line.css({'margin-left': '%spx' % (20*counter)})
                error.append(line)
    if is_html:
        error = Html('div', Html('h1', request.response.status), error)
    return error
1165976
def log_error(self, error, message, detail=None, strip=4):
        ""
        if message:
            msg = message + ": " + error
        else:
            msg = error

        tb = traceback.format_stack()
        if sys.version_info >= (3, 0):
            tb = tb[:-strip]
        else:
            tb = tb[strip:]

        self.errors.append({
            'message': msg,
            'traceback': tb,
            'detail': detail
        })