Package org.python.core

Examples of org.python.core.PyException


    private static final double NANOS_PER_SECOND = 1000000000.0;
    private static long initialClock;
    private static volatile boolean clockInitialized;

    private static void throwValueError(String msg) {
        throw new PyException(Py.ValueError, new PyString(msg));
    }
View Full Code Here


            shortdays[6] = names[1];
        }
        try {
            return shortdays[dow];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new PyException(Py.ValueError, new PyString("day of week out of range (0-6)"));
        }
    }
View Full Code Here

            }
        }
        try {
            return shortmonths[month0to11];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new PyException(Py.ValueError, new PyString("month out of range (1-12)"));
        }
    }
View Full Code Here

    public static void sleep(double secs) {
        try {
            java.lang.Thread.sleep((long)(secs * 1000));
        }
        catch (java.lang.InterruptedException e) {
            throw new PyException(Py.KeyboardInterrupt, "interrupted sleep");
        }
    }
View Full Code Here

            object = new HashMap<String, HashMap<String, Object>>();
            try {
                ReflectionHelper.setPrivateValue(plugindesc, "commands", object);
            } catch (Throwable t) {
                t.printStackTrace();
                throw new PyException(new PyString("error"), new PyString("Plugin commands list does not exist"));
            }
        }

        Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) object;

        if (map.containsKey(name)) {
            if (desc != null || usage != null || aliases != null)
                throw new PyException(new PyString("error"), new PyString("Plugin already has a command called '"+name+"'"));
            else
                return;
        }

        Map<String, Object> commandmap = new HashMap<String, Object>();
View Full Code Here

    /**
     * Check if we're allowed to register stuff, and if not, throw an exception
     */
    private void checkFrozen() {
        if (frozen)
            throw new PyException(new PyString("error"), new PyString("Cannot register handlers when frozen"));
    }
View Full Code Here

            sb.append(":</b> ");
        }
        sb.append("<u>");
        nodeRenderException = getRootCause(e);
        if (nodeRenderException instanceof PyException) {
            PyException ex = (PyException) nodeRenderException;
            if (ex.value != null) {
                sb.append(ex.value.toString());
            } else {
                sb.append(ex.toString());
            }
        } else if (nodeRenderException instanceof OutOfMemoryError) {
            sb.append("Out of memory. Are you trying to process an infinite list?");
        } else {
            sb.append(nodeRenderException.getMessage());
View Full Code Here

    @Override
    protected void unWrapAndThrowWfsException(ScriptException e)
            throws ScriptException {
        if (e.getCause() instanceof PyException) {
            PyException pye = (PyException) e.getCause();
            if (pye.value != null) {
                Object wfse = pye.value.__tojava__(Exception.class);
                if (wfse instanceof WFSException) {
                    throw (WFSException) wfse;
                }
View Full Code Here

        try {
            ProgressListener listener = new DefaultProgressListener();
            p.execute(inputs, listener);
            fail("Should have thrown a WPSException");
        } catch (ProcessException processException) {
            PyException pyException = (PyException) processException.getCause();
            WPSException e = (WPSException) pyException.getCause();
            assertEquals("Forbidden", e.getMessage());
            assertEquals("userInput", e.getCode());
            assertEquals("distance", e.getLocator());
        }
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyException

Copyright © 2018 www.massapicom. 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.