Handle user errors. Print out a message and a description of the
    error, along with the line number and routine where it occured.
    The file and line number will be the deepest stack frame that is
    not part of SCons itself.
327627
def _scons_user_error(e):
    
    global print_stacktrace
    etype, value, tb = sys.exc_info()
    if print_stacktrace:
        traceback.print_exception(etype, value, tb)
    filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_tb(tb))
    sys.stderr.write("\nscons: *** %s\n" % value)
    sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
    sys.exit(2)
1031829
def soft_error(self, message):
        

        self.print_usage(sys.stderr)
        args = {'prog': self.prog, 'message': message}
        self._print_message(
            _('%(prog)s: error: %(message)s\n') % args, sys.stderr)
819421
def handle_error(self, error, req, schema, error_status_code, error_headers):
        
        status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS
        response = exception_response(
            status_code,
            detail=text_type(error),
            headers=error_headers,
            content_type="application/json",
        )
        body = json.dumps(error.messages)
        response.body = body.encode("utf-8") if isinstance(body, text_type) else body
        raise response
231152
def error(self, message, print_help=False):
        """"""
        if 'too few arguments' in message.lower():
            target = sys.argv.pop(0)
            sys.argv.insert(
                0, os.path.basename(target) or os.path.relpath(target))
            message = ("%s. Try getting help with `%s --help`"
                       % (message, " ".join(sys.argv)))
        if print_help:
            self.print_help()
        else:
            self.print_usage()
        sys.stderr.write('\nerror: %s\n' % message)
        sys.exit(2)
982849
def print_error(input, err, scanner):
    """"""
    p = err.pos
    # Figure out the line number
    line = input[:p].count('\n')
    print err.msg + " on line " + repr(line + 1) + ":"
    # Now try printing part of the line
    text = input[max(p - 80, 0):
        p + 80]
    p = p - max(p - 80, 0)

    # Strip to the left
    i = text[:p].rfind('\n')
    j = text[:p].rfind('\r')
    if i < 0 or (0 <= j < i):
        i = j
    if 0 <= i < p:
        p = p - i - 1
        text = text[i + 1:]

    # Strip to the right
    i = text.find('\n', p)
    j = text.find('\r', p)
    if i < 0 or (0 <= j < i):
        i = j
    if i >= 0:
        text = text[:i]

    # Now shorten the text
    while len(text) > 70 and p > 60:
        # Cut off 10 chars
        text = "..." + text[10:]
        p = p - 7

    # Now print the string, along with an indicator
    print '> ', text
    print '> ', ' ' * p + '^'
    print 'List of nearby tokens:', scanner
60611
def _stack_format (stack):
    
    s = StringIO()
    s.write('Traceback:')
    s.write(os.linesep)
    for frame, fname, lineno, method, lines, dummy in reversed(stack):
        s.write('  File %r, line %d, in %s' % (fname, lineno, method))
        s.write(os.linesep)
        s.write('    %s' % lines[0].lstrip())
        if PRINT_LOCALVARS:
            for key, value in frame.f_locals.items():
                s.write("      %s = " % key)
                # be careful not to cause a new error in the error output
                try:
                    s.write(repr(value))
                    s.write(os.linesep)
                except Exception:
                    s.write("error in repr() call%s" % os.linesep)
    return s.getvalue()
1117416
function _errorHandler($errNo, $errMsg, $errFile, $errLine, $errCont)
    {
        $errType = $this->_getErrorTypes();

        $errorMessage = $errType[$errNo] . "\t\"" . trim($errMsg) . "\"\t" . $errFile . ' ' . 'Line:' . $errLine;

        if (self::$_config['errors']['logAll']) {
            error_log('JBDump:' . $errorMessage);
        }

        if (!(error_reporting() & $errNo) || error_reporting() == 0 || (int)ini_get('display_errors') == 0) {

            if (self::$_config['errors']['logHidden']) {
                $errorMessage = date(self::DATE_FORMAT, time()) . ' ' . $errorMessage . PHP_EOL;

                $logPath = self::$_config['log']['path']
                    . '/' . self::$_config['log']['file'] . '_error_' . date('Y.m.d') . '.log';

                error_log($errorMessage, 3, $logPath);
            }

            return false;
        }


        $errFile = $this->_getRalativePath($errFile);
        $result  = array(
            'file'    => $errFile . ' : ' . $errLine,
            'type'    => $errType[$errNo] . ' (' . $errNo . ')',
            'message' => $errMsg,
        );

        if (self::$_config['errors']['context']) {
            $result['context'] = $errCont;
        }

        if (self::$_config['errors']['errorBacktrace']) {
            $trace = debug_backtrace();
            unset($trace[0]);
            $result['backtrace'] = $this->convertTrace($trace);
        }

        if ($this->_isLiteMode()) {
            $errorInfo = array(
                'message' => $result['type'] . ' / ' . $result['message'],
                'file'    => $result['file']
            );
            $this->_dumpRenderLite($errorInfo, '* ' . $errType[$errNo]);

        } else {
            $desc = '<b style="color:red;">*</b> ' . $errType[$errNo] . ' / ' . $this->_htmlChars($result['message']);
            $this->dump($result, $desc);
        }

        return true;
    }
966048
def handle_error(self, exc, msg):
        
        if self.mode == "api":
            logger.error(msg)
            if self.strict:
                raise exc
        elif self.mode == "cli":
            sys.stderr.write(msg)
            sys.exit(1)
24803
function handleError(call, error) {
  var statusMetadata = new Metadata();
  var status = {
    code: constants.status.UNKNOWN,
    details: 'Unknown Error'
  };
  if (error.hasOwnProperty('message')) {
    status.details = error.message;
  }
  if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
    status.code = error.code;
    if (error.hasOwnProperty('details')) {
      status.details = error.details;
    }
  }
  if (error.hasOwnProperty('metadata')) {
    statusMetadata = error.metadata;
  }
  status.metadata = statusMetadata._getCoreRepresentation();
  var error_batch = {};
  if (!call.metadataSent) {
    error_batch[grpc.opType.SEND_INITIAL_METADATA] =
        (new Metadata())._getCoreRepresentation();
  }
  error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
  call.startBatch(error_batch, function(){});
}
432781
public static function handleError($__exc_errno, $__exc_errstr, $__exc_errfile, $__exc_errline, $__exc_errcontext)
    {
        // If a command is called with "@", then we should return
        if (error_reporting() == 0) {
            return true;
        }

        if (class_exists('\QApplicationBase')) {
            \QApplicationBase::$ErrorFlag = true;
        }

        global $__exc_strType;
        if (isset($__exc_strType)) {
            return true;
        } // Already handled elsewhere, avoi looping

        $__exc_strType = "Error";
        //$__exc_strMessage = $__exc_errstr;

        switch ($__exc_errno) {
            case E_ERROR:
                $__exc_strObjectType = "E_ERROR";
                break;
            case E_WARNING:
                $__exc_strObjectType = "E_WARNING";
                break;
            case E_PARSE:
                $__exc_strObjectType = "E_PARSE";
                break;
            case E_NOTICE:
                $__exc_strObjectType = "E_NOTICE";
                break;
            case E_STRICT:
                $__exc_strObjectType = "E_STRICT";
                break;
            case E_CORE_ERROR:
                $__exc_strObjectType = "E_CORE_ERROR";
                break;
            case E_CORE_WARNING:
                $__exc_strObjectType = "E_CORE_WARNING";
                break;
            case E_COMPILE_ERROR:
                $__exc_strObjectType = "E_COMPILE_ERROR";
                break;
            case E_COMPILE_WARNING:
                $__exc_strObjectType = "E_COMPILE_WARNING";
                break;
            case E_USER_ERROR:
                $__exc_strObjectType = "E_USER_ERROR";
                break;
            case E_USER_WARNING:
                $__exc_strObjectType = "E_USER_WARNING";
                break;
            case E_USER_NOTICE:
                $__exc_strObjectType = "E_USER_NOTICE";
                break;
            case E_DEPRECATED:
                $__exc_strObjectType = 'E_DEPRECATED';
                break;
            case E_USER_DEPRECATED:
                $__exc_strObjectType = 'E_USER_DEPRECATED';
                break;
            case E_RECOVERABLE_ERROR:
                $__exc_strObjectType = 'E_RECOVERABLE_ERROR';
                break;
            default:
                $__exc_strObjectType = "Unknown";
                break;
        }

        $__exc_strFilename = $__exc_errfile;
        $__exc_intLineNumber = $__exc_errline;

        $__exc_strStackTrace = QcubedGetBacktrace();

        if (ob_get_length()) {
            $__exc_strRenderedPage = ob_get_contents();
            ob_clean();
        }

        // Call to display the Error Page (as defined in configuration.inc.php)
        if (defined('QCUBED_ERROR_PAGE_PHP')) {
            require(__DOCROOT__ . QCUBED_ERROR_PAGE_PHP);
        } else {
            // Error in installer or similar - QCUBED_ERROR_PAGE_PHP constant is not defined yet.
            echo "error: errno: " . $__exc_errno . "<br/>" . $__exc_errstr . "<br/>" . $__exc_errfile . ":" . $__exc_errline . "<br/>" . implode(', ',
                    $__exc_errcontext);
        }
        exit();
    }
546827
def handle_err(*args):
    
    if DEBUG:
        print_err(traceback.format_exc(), color=False)
    else:
        print_err(*args, newline=True)
914468
def handle_errors(callback, parsed=None, out=sys.stderr):

    """"""

    try:
        if parsed:
            return callback(parsed)
        else:
            return callback()
    except DeploymentError as e:
        traceback.print_exc(file=out)
        print(e, file=out)
        if hasattr(e, 'value') and hasattr(e.value, 'args') and len(e.value.args) > 0 and \
                'open_sftp_client' in e.value.args[0]:
            print('Timeout', file=out)
            return TIMEOUT
        return DEPLOYMENT_ERROR
    except MalformedResponseError as e:
        traceback.print_exc(file=out)
        print(e, file=out)
        if 'Service Unavailable' in e.body:
            return SERVICE_UNAVAILABLE
        return MALFORMED_RESPONSE
    except SystemExit:
        pass
    except:
        traceback.print_exc(file=out)
        return EXCEPTION
208367
def error(self, msg, *args, **kwargs):
        
        kwargs.setdefault('inc_stackinfo', True)
        kwargs.setdefault('inc_multiproc', True)
        self.log(ERROR, msg, args, **kwargs)
860641
function handleError(err, getContext, lax) {

    var ctx = getContext();

    var line = ctx.line,
        column = ctx.column,
        data = ctx.data;

    // we receive the full context data here,
    // for elements trim down the information
    // to the tag name, only
    if (data.charAt(0) === '<' && data.indexOf(' ') !== -1) {
      data = data.slice(0, data.indexOf(' ')) + '>';
    }

    var message =
      'unparsable content ' + (data ? data + ' ' : '') + 'detected\n\t' +
        'line: ' + line + '\n\t' +
        'column: ' + column + '\n\t' +
        'nested error: ' + err.message;

    if (lax) {
      context.addWarning({
        message: message,
        error: err
      });

      return true;
    } else {
      throw error(message);
    }
  }
961515
def _error_detail(data, item):
    '''
    
    '''
    err = item['errorDetail']
    if 'code' in err:
        try:
            msg = ': '.join((
                item['errorDetail']['code'],
                item['errorDetail']['message']
            ))
        except TypeError:
            msg = '{0}: {1}'.format(
                item['errorDetail']['code'],
                item['errorDetail']['message'],
            )
    else:
        msg = item['errorDetail']['message']
    data.append(msg)
521119
def handleError(self, record):
        '''
        
        '''
        handled = False
        if sys.stderr and sys.version_info >= (3, 5, 4):
            t, v, tb = sys.exc_info()
            if t.__name__ in 'FileNotFoundError':
                sys.stderr.write('[WARNING ] The log_file does not exist. Logging not setup correctly or syslog service not started.\n')
                handled = True

        if not handled:
            super(SysLogHandler, self).handleError(record)
441377
def handle_api_exceptions(
    ctx, opts, context_msg=None, nl=False, exit_on_error=True, reraise_on_error=False
):
    """"""
    # flake8: ignore=C901
    # Use stderr for messages if the output is something else (e.g.  # JSON)
    use_stderr = opts.output != "pretty"

    try:
        yield
    except ApiException as exc:
        if nl:
            click.echo(err=use_stderr)
            click.secho("ERROR: ", fg="red", nl=False, err=use_stderr)
        else:
            click.secho("ERROR", fg="red", err=use_stderr)

        context_msg = context_msg or "Failed to perform operation!"
        click.secho(
            "%(context)s (status: %(code)s - %(code_text)s)"
            % {
                "context": context_msg,
                "code": exc.status,
                "code_text": exc.status_description,
            },
            fg="red",
            err=use_stderr,
        )

        detail, fields = get_details(exc)
        if detail or fields:
            click.echo(err=use_stderr)

            if detail:
                click.secho(
                    "Detail: %(detail)s"
                    % {"detail": click.style(detail, fg="red", bold=False)},
                    bold=True,
                    err=use_stderr,
                )

            if fields:
                for k, v in six.iteritems(fields):
                    field = "%s Field" % k.capitalize()
                    click.secho(
                        "%(field)s: %(message)s"
                        % {
                            "field": click.style(field, bold=True),
                            "message": click.style(v, fg="red"),
                        },
                        err=use_stderr,
                    )

        hint = get_error_hint(ctx, opts, exc)
        if hint:
            click.echo(
                "Hint: %(hint)s" % {"hint": click.style(hint, fg="yellow")},
                err=use_stderr,
            )

        if opts.verbose and not opts.debug:
            if exc.headers:
                click.echo(err=use_stderr)
                click.echo("Headers in Reply:", err=use_stderr)
                for k, v in six.iteritems(exc.headers):
                    click.echo(
                        "%(key)s = %(value)s" % {"key": k, "value": v}, err=use_stderr
                    )

        if reraise_on_error:
            six.reraise(*sys.exc_info())

        if exit_on_error:
            ctx.exit(exc.status or 1)