Checks if given function raises an error

@method raises
13175
function raises(fn, errorValidator) {
    check.verify.fn(fn, 'expected function that raises');
    try {
      fn();
    } catch (err) {
      if (typeof errorValidator === 'undefined') {
        return true;
      }
      if (typeof errorValidator === 'function') {
        return errorValidator(err);
      }
      return false;
    }
    // error has not been raised
    return false;
  }
109075
def does_not_raise(self, function, *args, **kwargs):
        
        try:
            return function(*args, **kwargs)
        except Exception as e:
            self.log_error("{} did raise {}: {}".format(
                function.__name__,
                type(e).__name__, e
            ), None)
325338
static function is_error( $emask = null ) {
		if( $emask === null ){
			return (bool) self::get_global_level();
		}	
		else {
			return (bool) ( self::get_global_level() & $emask );
		}
	}
147160
def fini ( method )
      raise TypeError, error_message(method, __method__) unless method.instance_of? Method
      @fini = method
    end
98949
function (/*util*/) {

      function compare(actual, expected) {
        return {
          pass: actual instanceof Error && ('' + actual).indexOf(expected) >= 0
        }
      }

      return {compare: compare}
    }
683950
def check_errors
      if @value && @value.is_a?(Numeric)
        if @args.is_a?(Hash)

          @args.each do |arg, val|
            case arg
            when :min
              add_error("number must be greater than #{val}") if @value < val
            when :max
              add_error("number must be less than #{val}") if @value > val
            end
          end

        end
      else
        message = (@args.is_a?(Hash) && @args[:message]) || 'must be a number'
        add_error(message)
      end
    end
1329326
def validate(retval, func, args):
    # type: (int, Any, Tuple[Any, Any]) -> Optional[Tuple[Any, Any]]
    

    if retval != 0 and not ERROR.details:
        return args

    err = "{}() failed".format(func.__name__)
    details = {"retval": retval, "args": args}
    raise ScreenShotError(err, details=details)
182657
def method_missing(method, *args, &code)
    success = false
    result  = nil

    if method.to_s.match(/^set\_([a-z].*)$/)
      name = $1.to_sym

      if @types.has_key?(name) && args.length > 2
        @types[name].set([ args[0], args[1] ], args[2]) if args.length > 2
        success = true
      end

    elsif method.to_s.match(/^remove\_([a-z].*)$/)
      name = $1.to_sym

      if @types.has_key?(name) && args.length > 0
        @types[name].delete([ args[0], args[1] ])
        success = true
      end

    else
      name = @plurals[method.to_sym]

      if name && @types.has_key?(name)
        result  = @types[name]
        success = true
      end
    end
    super unless success # Raise NoMethodError
    result
  end
435156
def validate_call(kwargs, returns, is_method=False):
    
    def decorator(func):
        @wraps(func)
        def inner(*passed_args, **passed_kwargs):
            # Enforce no positional args
            # first argument of instance method and class method is always positonal so we need
            # to make expception for them. Static methods are still validated according to standard rules
            # this check happens before methods are bound, so instance method is still a regular function
            max_allowed_passed_args_len = 0
            if is_method and type(func) in (types.FunctionType, classmethod):
                max_allowed_passed_args_len = 1

            if len(passed_args) > max_allowed_passed_args_len:
                raise PositionalError('You cannot call this with positional arguments.')
            # Validate keyword arguments
            validate(kwargs, passed_kwargs, 'keyword arguments')
            # Call callable
            return_value = func(*passed_args, **passed_kwargs)
            # Validate return value
            validate(returns, return_value, 'return value')
            return return_value
        inner.__wrapped__ = func
        # caveat: checking for f.__validated__ will only work if @validate_call
        # is not masked by other decorators except for @classmethod or @staticmethod
        inner.__validated__ = True
        return inner
    return decorator
1170953
def _method_error_handler(self, response: Dict[str, Any]):
        
        exp = response.get('MESSAGE')
        code = response.get("CODE")
        ID = exp.get("ID")
        raise abort(code, ID=ID, message=exp.get('MESSAGE'))
209961
function raise(err, parameters, cause) {
  if(!(err instanceof Error)) {
    err = wrap(err, parameters, cause);
  }
  throw err;
}
530776
def method_missing(method, *args, &block)
      if method[-1] == '='
        # setter
        key = method.slice(0...-1).to_sym

        unless has_key?(key)
          super
        end
        self[key] = args[0]
      else
        unless has_key?(method)
          super
        end

        prop = self[method]
        if prop.is_a? JSFunction
          prop.call_with_instance(self, *args, &block)
        else
          prop
        end
      end
    end
981006
def return_false_on_exception(func):
    
    @wraps(func)
    def exceptfalse(*args, **kwargs):
        if not kwargs.pop('raise_exceptions', False):
            try:
                return func(*args, **kwargs)
            except Exception:
                return False
        else:
            return func(*args, **kwargs)
    return exceptfalse
401739
def bool_check(*args, func=None):
    """"""
    func = func or inspect.stack()[2][3]
    for var in args:
        if not isinstance(var, bool):
            name = type(var).__name__
            raise BoolError(
                f'Function {func} expected bool, {name} got instead.')
1163483
function isValidMethodSpec(methodSpec, methodName) {
  var valid = true;
  var printIgnoredMethodOnce = _.once(function() { console.log(methodName + ' from ' + path.basename(xml2js.opts.custom) + ' is omitted from JS documentation.'); });
  function checkRule(rule, errMsg) {
    if (!rule) {
      printIgnoredMethodOnce();
      console.log('  ' + errMsg);
      valid = false;
    }
  }
  checkRule(_.has(methodSpec, 'description'), 'no description given');
  checkRule(_.has(methodSpec, 'params'), 'no params given (specify "params": {} for no params)');
  _.each(methodSpec.params, function(paramSpec, paramName) {
    checkRule(_.has(paramSpec, 'type'), 'no type given for param ' + paramName);
    checkRule(_.has(paramSpec, 'description'), 'no description given for param ' + paramName);
  });
  checkRule(_.has(methodSpec, 'return'), 'no return given (specify "return": {} for no return value)');
  checkRule(_.has(methodSpec.return, 'type'), 'no type given for return value');
  checkRule(_.has(methodSpec.return, 'description'), 'no description given for return value');
  return valid;
}
1263469
def maybe_raise(cls, error_type, ignores=None):
        
        ignores = set(ignores or [])
        ignores.add(ErrorType.Ok)
        if error_type not in ignores:
            raise LibError(error_type)
683842
def _validate_func_args(func, kwargs):
    """"""

    args, varargs, varkw, defaults = inspect.getargspec(func)
    if set(kwargs.keys()) != set(args[1:]): # chop off self
        raise TypeError("decorator kwargs do not match %s()'s kwargs"
                        % func.__name__)