Needs for cases when custom exceptions needs a several required arguments
428944
def build_new_exception e
        e.class.new(e.message)
      rescue
        Exception.new e.message
      end
1164784
def _parse_new_contract_args(*args, **kwargs):
    """"""
    # No arguments
    if (not args) and (not kwargs):
        return [
            {
                "name": "argument_invalid",
                "msg": "Argument `*[argument_name]*` is not valid",
                "type": RuntimeError,
            }
        ]
    # Process args
    if (len(args) > 1) or ((len(args) == 1) and kwargs):
        raise TypeError("Illegal custom contract exception definition")
    if len(args) == 1:
        return [dict([("name", "default")] + list(_format_arg(args[0]).items()))]
    # Process kwargs
    return [
        dict([("name", name)] + list(_format_arg(kwargs[name]).items()))
        for name in sorted(list(kwargs.keys()))
    ]
1049396
def template_exception_handler(fn, error_context, filename=None):
    """"""
    error_message = None
    if filename:
        error_context.update(filename=filename)
    try:
        return fn()
    except jinja2.TemplateSyntaxError as exc:
        error_context.update(filename=exc.filename, line_no=exc.lineno)
        error_message = exc.message
    except jinja2.TemplateError as exc:
        error_message = exc.message
    except Exception as exc:
        error_message = "%s" % exc

    raise TemplateError(message=error_message, context=error_context)
164085
def evaluate_exceptions(exceptions, options)
      exceptions.each do |exception|
        key = if exception.is_a?(Class) && exception <= Exception
          exception.name
        elsif exception.is_a?(String)
          exception
        else
          raise ArgumentError, "#{exception} isn't an Exception"
        end

        error_handlers << [key, options[:with]]
      end
    end
751818
function exception(type) {
	
	var message = errors[type];
	
	for(var i = 1; i < arguments.length; i++)
		message = message.replace('%', arguments[i].toString().replace(/\((.|\r\n|\n|\r)*/gm, ''));
	
	return "Exception: " + message;
}
1110889
def check_args(arguments, data_frame):
    
    stripped_args = [a[0] for a in arguments]
    df = data_frame.df
    # first make sure all args are valid
    for a in arguments:
        if a[0] not in df.index:
            print("-I- ignoring invalid argument: {}".format(a[0]))
            print("-")
    # next make sure required arguments are present
    condition = df['reqd']
    reqd_args = df[condition]
    for arg in reqd_args['arg_name']:
        if arg not in stripped_args:
            raise pmag.MissingCommandLineArgException("-"+arg)
    #next, assign any default values as needed

    #condition = df['default'] != '' # don't need this, and sometimes the correct default argument IS ''
    default_args = df #[condition]
    using_defaults = []
    for arg_name, row in default_args.iterrows():
        default = row['default']
        if arg_name not in stripped_args:
            using_defaults.append(arg_name)
            arguments.append([arg_name, default])
    using_defaults = ["-" + arg for arg in using_defaults]
    print('Using default arguments for: {}'.format(', '.join(using_defaults)))
    return arguments
926103
public static void requireArgValid(@NotNull final String name, @NotNull final File value) throws ConstraintViolationException {
        // CHECKSTYLE:ON
        if (!value.exists()) {
            throw new ConstraintViolationException("The argument '" + name + "' is not an existing file: '" + value + "'");
        }
    }
1287659
def exception_wrapper(f):
    """"""
    @wraps(f)
    def wrapper(*args, **kwds):
        try:
            return f(*args, **kwds)
        except dbus.exceptions.DBusException as err:
            _args = err.args
            raise PyMPRISException(*_args)
    return wrapper
807191
def check_params(**kwargs):
    

    missing_params = []
    check = True

    for param in kwargs:
        if kwargs[param] is None:
            missing_params.append(param)

    if len(missing_params) > 0:
        print("POT - Warning: following necessary parameters are missing")
        for p in missing_params:
            print("\n", p)

        check = False

    return check
436208
public static String requireNotEmpty(String obj, String errorText) {
    if (isBlank(obj)) {
      throw new IllegalArgumentException(errorText);
    }
    return obj;
  }
874832
def check_method_requirements(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        error_message = "You must provide {error_field} in {cls} to get access to the default {method} method"
        error_data = {'cls': args[0].__class__.__name__, 'method': request.method.lower()}

        if request.method != 'DELETE':
            if not hasattr(args[0], 'schema'):
                error_data.update({'error_field': 'a schema class'})
                raise Exception(error_message.format(**error_data))

        return func(*args, **kwargs)
    return wrapper
594897
public static function getRequiredArgsError($args, $requiredArgs)
    {
        if (!is_array($args) && !is_object($args)) {
            return sprintf(__('invalid type "%s" for $args', 'themaster'), gettype($args));
        }
        if (!is_array($requiredArgs) && !is_object($args)) {
            return sprintf(__('invalid type "%s" for $requiredArgs', 'themaster'), gettype($requiredArgs));
        }

        $missing = array();
        foreach ($requiredArgs as $req) {
            if (!@isset($args[$req]) && !@isset($args->$req)) {
                $missing[] = $req;
            }
        }
        
        if (count($missing) == 0) {
            return false;
        } else {
            return sprintf(
                __('Missing %s as %s.', 'themaster'),
                self::readableList(
                    $missing,
                    ' '.__('and').' ',
                    ', ',
                    null,
                    '"'
                ),
                (count($missing) === 1 ? 'a key' : 'keys')
            );
        }
    }
392899
def method_missing mtd, *args
      if mtd.to_s.chars.to_a.last == '='
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 1)" if args.length != 1
        attributes[mtd.to_s.slice(0,mtd.to_s.length-1)] = args.first
      else
        raise ArgumentError, "Invalid number of arguments (#{args.length} for 0)" if args.length != 0
        attributes[mtd.to_s]
      end
    end
505544
def error_wrapper(fn, error_class):  # type: (Callable or None, Exception) -> ...
    
    def wrapper(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except Exception as e:
            six.reraise(error_class, error_class(e), sys.exc_info()[2])

    return wrapper
388677
def check_arguments(cls, passed):
        """"""
        defaults = list(cls.default_arguments().keys())
        template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? "
                    "Supported key arguments: {defaults}")
        fails = []
        for arg in passed:
            if arg not in defaults:
                warn(template.format(argument=arg,
                                     cname=cls.__name__,
                                     defaults=defaults))
                fails.append(arg)

        return any(fails)
1088005
function need(args) {
        var argsArray, restArgs;

        if (!args) {
            return args;
        }

        argsArray = Array.prototype.slice.call(args);
        restArgs = Array.prototype.slice.call(arguments, 1);

        if (isArgumentObject(args)) {
            return argCheck(argsArray, restArgs);
        }

        return objectCheck(args, restArgs);
    }
840716
def _validate(self, args, kwargs):
    """"""
    def error(exception_type, arg_name=None, **msg_kwargs):
      if arg_name is None:
        arg_name = args[0] if args else '<unknown>'
      raise exception_type(self.scope, arg_name, **msg_kwargs)

    if not args:
      error(NoOptionNames)
    # validate args.
    for arg in args:
      if not arg.startswith('-'):
        error(OptionNameDash, arg_name=arg)
      if not arg.startswith('--') and len(arg) > 2:
        error(OptionNameDoubleDash, arg_name=arg)

    # Validate kwargs.
    if 'implicit_value' in kwargs and kwargs['implicit_value'] is None:
      error(ImplicitValIsNone)

    # Note: we check for list here, not list_option, because we validate the provided kwargs,
    # not the ones we modified.  However we temporarily also allow list_option, until the
    # deprecation is complete.
    if 'member_type' in kwargs and kwargs.get('type', str) not in [list, list_option]:
      error(MemberTypeNotAllowed, type_=kwargs.get('type', str).__name__)

    if kwargs.get('member_type', str) not in self._allowed_member_types:
      error(InvalidMemberType, member_type=kwargs.get('member_type', str).__name__)

    for kwarg in kwargs:
      if kwarg not in self._allowed_registration_kwargs:
        error(InvalidKwarg, kwarg=kwarg)

      # Ensure `daemon=True` can't be passed on non-global scopes (except for `recursive=True`).
      if (kwarg == 'daemon' and self._scope != GLOBAL_SCOPE and kwargs.get('recursive') is False):
        error(InvalidKwargNonGlobalScope, kwarg=kwarg)

    removal_version = kwargs.get('removal_version')
    if removal_version is not None:
      validate_deprecation_semver(removal_version, 'removal version')