Convert any return code a BuildError Exception.

    :Parameters:
      - `status`: can either be a return code or an Exception.

    The buildError.status we set here will normally be
    used as the exit status of the "scons" process.
488621
def convert_to_BuildError(status, exc_info=None):
    

    if not exc_info and isinstance(status, Exception):
        exc_info = (status.__class__, status, None)


    if isinstance(status, BuildError):
        buildError = status
        buildError.exitstatus = 2   # always exit with 2 on build errors
    elif isinstance(status, ExplicitExit):
        status = status.status
        errstr = 'Explicit exit, status %s' % status
        buildError = BuildError(
            errstr=errstr,
            status=status,      # might be 0, OK here
            exitstatus=status,      # might be 0, OK here
            exc_info=exc_info)
    elif isinstance(status, (StopError, UserError)):
        buildError = BuildError(
            errstr=str(status),
            status=2,
            exitstatus=2,
            exc_info=exc_info)
    elif isinstance(status, shutil.SameFileError):
        # PY3 has a exception for when copying file to itself
        # It's object provides info differently than below
        try:
            filename = status.filename
        except AttributeError:
            filename = None
        
        buildError = BuildError( 
            errstr=status.args[0],
            status=status.errno,
            exitstatus=2,
            filename=filename,
            exc_info=exc_info)

    elif isinstance(status, (EnvironmentError, OSError, IOError)):
        # If an IOError/OSError happens, raise a BuildError.
        # Report the name of the file or directory that caused the
        # error, which might be different from the target being built
        # (for example, failure to create the directory in which the
        # target file will appear).
        try:
            filename = status.filename
        except AttributeError:
            filename = None

        buildError = BuildError( 
            errstr=status.strerror,
            status=status.errno,
            exitstatus=2,
            filename=filename,
            exc_info=exc_info)
    elif isinstance(status, Exception):
        buildError = BuildError(
            errstr='%s : %s' % (status.__class__.__name__, status),
            status=2,
            exitstatus=2,
            exc_info=exc_info)
    elif SCons.Util.is_String(status):
        buildError = BuildError(
            errstr=status,
            status=2,
            exitstatus=2)
    else:
        buildError = BuildError(
            errstr="Error %s" % status,
            status=status,
            exitstatus=2)
    
    #import sys
    #sys.stderr.write("convert_to_BuildError: status %s => (errstr %s, status %s)\n"%(status,buildError.errstr, buildError.status))
    return buildError
171428
def status_code(self):
        
        try:
            return self._status_code
        except AttributeError:
            self._status_code = self._response.getcode()
        return self._status_code
1144650
def validate_statusline(self, valid_statusline):
        
        code = self.get_statuscode()
        try:
            code = int(code)
            assert(code > 0)
            return True
        except(ValueError, AssertionError):
            self.statusline = valid_statusline
            return False
512301
def _error_handling(self, res):
        

        # making the error handling generic so if an status_code starting with 2 doesn't exist, we raise the error
        if res.status_code // 100 != 2:
            error = self._get_response_json(res)
            raise exceptions.KeenApiError(error)
508144
def status(reason = false)
      case @status_code
      when SUCCESS      then 'success'
      when ERROR        then 'error' + (reason ? " (#{truncated_error})" : "")
      when CONTINUE     then 'continue'
      when RETRY        then 'retry' + (reason ? " (#{@content})" : "")
      when NON_DELIVERY then 'non-delivery' + (reason ? " (#{@content})" : "")
      when MULTICAST    then 'multicast'
      when CANCEL       then 'cancel' + (reason ? " (#{@content})" : "")
      end
    end
100438
def on_complete(env)
      status_code   = env[:status].to_i
      service_error = Github::Error::ServiceError
      error_class = service_error.error_mapping[status_code]
      if !error_class and (400...600) === status_code
        error_class = service_error
      end
      raise error_class.new(env) if error_class
    end
695896
function _buildError(url, status, method, response) {
    var errorData = response || {};

    errorData.status = status;
    errorData.url = url;
    errorData.method = method;

    return errorData;
  }
274047
def reset_error_status(self):
        
        try:
            return self.feature_error or self.scenario_error
        finally:
            self.feature_error = False
            self.scenario_error = False
877284
def _convert_status(self, msg):
        
        code = msg.get_int()
        text = msg.get_text()
        if code == SFTP_OK:
            return
        elif code == SFTP_EOF:
            raise EOFError(text)
        elif code == SFTP_NO_SUCH_FILE:
            # clever idea from john a. meinel: map the error codes to errno
            raise IOError(errno.ENOENT, text)
        elif code == SFTP_PERMISSION_DENIED:
            raise IOError(errno.EACCES, text)
        else:
            raise IOError(text)
1247217
protected StatusObject generateErrorResult(String code, Throwable error) {
        // Construct error object to return
        String message = "";
        while (error != null && error.getCause() != null) {
            error = error.getCause();
        }
        if (error != null && error.getMessage() != null) {
            message = error.getMessage();
        }
        StatusObject status = new StatusObject(code, "error", message);
        if (error instanceof ClientDetailsException) {
            // Return exception details to client
            status.setApplication(((ClientDetailsException) error).getParameters());
            if (((ClientDetailsException) error).includeStacktrace()) {
                List<String> stack = new ArrayList<String>();
                for (StackTraceElement element : error.getStackTrace()) {
                    stack.add(element.toString());
                }
                status.setAdditional("stacktrace", stack);
            }
        } else if (error != null) {
            status.setApplication(error.getClass().getCanonicalName());
            List<String> stack = new ArrayList<String>();
            for (StackTraceElement element : error.getStackTrace()) {
                stack.add(element.toString());
            }
            status.setAdditional("stacktrace", stack);
        }
        return status;
    }
1121628
def check_status_code(response, codes=None):
    
    codes = codes or [httplib.OK]
    checker = (
        codes
        if callable(codes)
        else lambda resp: resp.status_code in codes
    )
    if not checker(response):
        raise exceptions.ApiError(response, response.json())
565214
def check_error_code(self):
        
        # start off with STATUS_SUCCESS as a baseline
        status = NtStatusCodes.STATUS_SUCCESS

        error_code = self['errorCode']
        if error_code.isValue:
            # ASN.1 Integer is stored as an signed integer, we need to
            # convert it to a unsigned integer
            status = ctypes.c_uint32(error_code).value

        if status != NtStatusCodes.STATUS_SUCCESS:
            raise NTStatusException(status)
1139456
def handle_error(self, error, req, schema):
        

        status_code = getattr(error, "status_code", self.DEFAULT_VALIDATION_STATUS)
        abort(status_code, exc=error, messages=error.messages, schema=schema)
771432
def add_status_code(code):
    

    def class_decorator(cls):
        cls.status_code = code
        _sanic_exceptions[code] = cls
        return cls

    return class_decorator
923799
def status(self, status):
        
        allowed_values = ["pending", "awaitingRetry", "successful", "failed"]
        if status is not None and status not in allowed_values:
            raise ValueError(
                "Invalid value for `status` ({0}), must be one of {1}"
                .format(status, allowed_values)
            )

        self._status = status
1207753
function statusCodes(allowed, ignored, options) {
  var stream = new Transform({objectMode: true});
  var errored = false;

  stream._transform = function (page, _, callback) {
    if (errored) return callback(null);
    if (ignored && ignored.indexOf(page.statusCode) !== -1) return callback(null);
    if (!allowed || allowed.indexOf(page.statusCode) !== -1) {
      stream.push(page);
      return callback(null);
    }
    errored = true;
    stream.emit('error', new Error('Invalid status code ' + page.statusCode + ' - ' + page.url));
    callback(null);
  };

  return stream;
}
1074241
def status(**connection_args):
    '''
    
    '''
    dbc = _connect(**connection_args)
    if dbc is None:
        return {}
    cur = dbc.cursor()
    qry = 'SHOW STATUS'
    try:
        _execute(cur, qry)
    except OperationalError as exc:
        err = 'MySQL Error {0}: {1}'.format(*exc.args)
        __context__['mysql.error'] = err
        log.error(err)
        return {}

    ret = {}
    for _ in range(cur.rowcount):
        row = cur.fetchone()
        ret[row[0]] = row[1]
    return ret