Package org.jruby

Examples of org.jruby.Ruby.newArgumentError()


            Passwd pwd = runtime.getPosix().getpwnam(nam);
            if (pwd == null) {
                if (Platform.IS_WINDOWS) {  // MRI behavior
                    return runtime.getNil();
                }
                throw runtime.newArgumentError("can't find user for " + nam);
            }
            return setupPasswd(recv.getRuntime(), pwd);
        } catch (RaiseException e) {
            throw e;
        } catch (Exception e) {
View Full Code Here


                RubyEvent event = null;
                try {
                    event = RubyEvent.valueOf(eventName);
                } catch (IllegalArgumentException iae) {}
               
                if (event == null) throw runtime.newArgumentError("unknown event: " + eventName);
               
                // a_call is call | b_call | c_call, and same as a_return.
                if (event == RubyEvent.A_CALL) {
                    events.add(RubyEvent.CALL);
                    events.add(RubyEvent.B_CALL);
View Full Code Here

            Group grp = runtime.getPosix().getgrnam(nam);
            if (grp == null) {
                if (Platform.IS_WINDOWS) {  // MRI behavior
                    return runtime.getNil();
                }
                throw runtime.newArgumentError("can't find group for " + nam);
            }
            return setupGroup(runtime, grp);
        } catch (RaiseException e) {
            throw e;
        } catch (Exception e) {
View Full Code Here

            Group gr = posix.getgrgid(gid);
            if(gr == null) {
                if (Platform.IS_WINDOWS) {  // MRI behavior
                    return runtime.getNil();
                }
                throw runtime.newArgumentError("can't find group for " + gid);
            }
            return setupGroup(runtime, gr);
        } catch (RaiseException re) {
            throw re;
        } catch (Exception e) {
View Full Code Here

                        forArity.add(constructor);
                    }
                }
               
                if (forArity.size() == 0) {
                    throw runtime.newArgumentError("wrong number of arguments for constructor");
                }

                JavaProxyConstructor matching = (JavaProxyConstructor)CallableSelector.matchingCallableArityN(
                        runtime, methodCache,
                        forArity.toArray(new JavaProxyConstructor[forArity.size()]), args, args.length);
View Full Code Here

                JavaProxyConstructor matching = (JavaProxyConstructor)CallableSelector.matchingCallableArityN(
                        runtime, methodCache,
                        forArity.toArray(new JavaProxyConstructor[forArity.size()]), args, args.length);

                if (matching == null) {
                    throw runtime.newArgumentError("wrong number of arguments for constructor");
                }

                Object[] newArgs = new Object[args.length];
                Class[] parameterTypes = matching.getParameterTypes();
                for (int i = 0; i < args.length; i++) {
View Full Code Here

       
        @JRubyMethod(name = "digest", required = 1, rest = true, meta = true)
        public static IRubyObject s_digest(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
            Ruby runtime = recv.getRuntime();
            if (args.length < 1) {
                throw runtime.newArgumentError("no data given");
            }
            RubyString str = args[0].convertToString();
            IRubyObject[] newArgs = new IRubyObject[args.length - 1];
            System.arraycopy(args, 1, newArgs, 0, args.length - 1);
            IRubyObject obj = ((RubyClass)recv).newInstance(context, newArgs, Block.NULL_BLOCK);
View Full Code Here

   
    @JRubyMethod(visibility = Visibility.PRIVATE)
    public IRubyObject initialize(ThreadContext context, Block block) {
        Ruby runtime = context.runtime;
       
        if (!block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without block");

        data = new FiberData(new SizedQueue(runtime, runtime.getClass("SizedQueue"), 1), context.getFiberCurrentThread(), this);
       
        FiberData currentFiberData = context.getFiber().data;
       
View Full Code Here

        if (isInfinity() && infinitySign > 0) return newInfinity(runtime, 1);

        // NOTE: MRI's sqrt precision is limited by 100,
        // but we allow values more than 100.
        int n = RubyNumeric.fix2int(arg);
        if (n < 0) throw runtime.newArgumentError("argument must be positive");

        n += 4; // just in case, add a bit of extra precision

        return new RubyBigDecimal(runtime, bigSqrt(value, new MathContext(n, RoundingMode.HALF_UP))).setResult();
    }
View Full Code Here

        if (arg0 instanceof RubyArray) {
            List list = ((RubyArray)arg0).getList();
            int len = list.size();

            if (len < 3 || len > 4) {
                throw runtime.newArgumentError("array size should be 3 or 4, "+len+" given");
            }

            // if array has 4 elements, third element is ignored
            host = list.size() == 3 ? list.get(2).toString() : list.get(3).toString();
            port = list.get(1).toString();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.