Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.smartbear.collab.client.Client.java

public JsonrpcCommandResponse addFilesToReview(String reviewId, List<ChangeList> changeLists)
        throws ServerURLException, CredentialsException, Exception {

    JsonrpcCommandResponse result;/*from   ww  w  . ja  v a 2 s  .c o  m*/

    List<JsonrpcCommand> methods = new ArrayList<JsonrpcCommand>();
    methods.add(new Authenticate(username, ticketId));
    methods.add(new AddFiles(reviewId, changeLists));
    try {

        JsonrpcResponse response = sendRequest(methods);
        result = response.getResults().get(0);
        if (result.getErrors() != null && result.getErrors().size() > 0) {
            throw new ServerURLException("Server communication error.");
        }
        result = response.getResults().get(1);

    } catch (IllegalArgumentException iae) {
        throw new ServerURLException(iae.getMessage());
    } catch (ProcessingException pe) {
        if (pe.getCause().getClass().equals(ConnectException.class)) {
            throw new ServerURLException(pe.getCause().getMessage());
        } else {
            throw new ServerURLException(pe.getMessage());
        }
    } catch (NotFoundException nfe) {
        throw new ServerURLException(nfe.getMessage());
    } catch (Exception e) {
        throw new CredentialsException(e.getMessage());
    }
    return result;
}

From source file:com.vsthost.rnd.DMatrixUtilsTest.java

/**
 * Testing ZMBD with predefined args./*  w  ww.j  a va  2 s  .c  o m*/
 */
public void testZmbd() {
    // Create a random generator:
    MersenneTwister randomGenerator = new MersenneTwister();

    // Create upper/lower bounds:
    double[] lowerSingle = new double[] { -5.0 };
    double[] upperSingle = new double[] { +5.0 };
    double[] lowerDouble = new double[] { -4.0, -4.0 };
    double[] upperDouble = new double[] { +1.0, +1.0 };
    double[] lowerTriple = new double[] { -1.0, -2.0, -3.0 };
    double[] upperTriple = new double[] { +1.0, +2.0, +3.0 };
    double[] lowerQuad = new double[] { -4.0, -4.0, -4.0, -4.0 };
    double[] upperQuad = new double[] { +1.0, +1.0, +1.0, +1.0 };
    double[] lowerReal = new double[] { -4.0, -1.0, -1.0, -4.0 };
    double[] upperReal = new double[] { +1.0, +5.0, +1.0, +1.0 };
    double[] lowerWZero = new double[] { -4.0, -0.000001, -1.0, -4.0 };
    double[] upperWZero = new double[] { +1.0, +5.0, +0.0000001, +1.0 };
    double[] lowerIllegal = new double[] { 44.0, -1.0, +1.0, -4.0 };
    double[] upperIllegal = new double[] { +1.0, +5.0, -1.0, +1.0 };

    // Means should always be zero:
    this.assertEquals(0.0,
            Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerSingle, upperSingle, randomGenerator))), 1E-8);
    this.assertEquals(0.0,
            Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerDouble, upperDouble, randomGenerator))), 1E-8);
    this.assertEquals(0.0,
            Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerTriple, upperTriple, randomGenerator))), 1E-8);
    this.assertEquals(0.0, Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerQuad, upperQuad, randomGenerator))),
            1E-8);
    this.assertEquals(0.0, Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerReal, upperReal, randomGenerator))),
            1E-8);
    this.assertEquals(0.0,
            Math.abs(DMatrixUtils.sum(DMatrixUtils.zmbd(lowerWZero, upperWZero, randomGenerator))), 1E-8);

    // Check boundaries:
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerSingle, upperSingle, randomGenerator),
            lowerSingle, upperSingle));
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerDouble, upperDouble, randomGenerator),
            lowerDouble, upperDouble));
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerTriple, upperTriple, randomGenerator),
            lowerTriple, upperTriple));
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerQuad, upperQuad, randomGenerator),
            lowerQuad, upperQuad));
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerReal, upperReal, randomGenerator),
            lowerReal, upperReal));
    this.assertEquals(-1, this.checkBoundaries(DMatrixUtils.zmbd(lowerWZero, upperWZero, randomGenerator),
            lowerWZero, upperWZero));

    // Expecting exceptions for dimension mismatch:
    try {
        DMatrixUtils.zmbd(lowerSingle, upperDouble, randomGenerator);
        fail("Dimension mismatch for boundaries must fail.");
    } catch (IllegalArgumentException exception) {
        if (!exception.getMessage().equals("Lower and upper bounds must be of same length.")) {
            fail("Dimension mismatch for boundaries must fail with proper message.");
        }
    }

    // Expecting exceptions for positive lower boundary:
    try {
        DMatrixUtils.zmbd(lowerIllegal, upperIllegal, randomGenerator);
        fail("Illegal lower/upper bound must fail");
    } catch (IllegalArgumentException exception) {
        if (!exception.getMessage().equals("Lower bounds must be equal to or less than upper bounds.")) {
            fail("Illegal lower/upper bounds must fail with proper message.");
        }
    }
}

From source file:co.paralleluniverse.springframework.web.method.support.FiberInvocableHandlerMethod.java

protected Object fiberDispatchInvoke(final Object... args) {
    final Object b = getBean();
    final Method m = getBridgedMethod();
    ReflectionUtils.makeAccessible(m);//from  w  w  w.ja v a2 s.  c  o m

    // Returning deferred even for normal return values, Spring return handlers will take care dynamically based on the actual returned value
    final DeferredResult ret = new DeferredResult();

    // The actual method execution and deferred completion is dispatched to a new fiber
    new Fiber(new SuspendableRunnable() {
        private Object deAsync(final Object o) throws SuspendExecution, Exception {
            if (o instanceof Callable)
                return deAsync(((Callable) o).call());
            else
                return o;
        }

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            try {
                Object originalRet = m.invoke(b, args);
                ret.setResult(deAsync(originalRet));
            } catch (IllegalArgumentException ex) {
                assertTargetBean(m, b, args);
                ret.setErrorResult(
                        new IllegalStateException(getInvocationErrorMessage(ex.getMessage(), args), ex));
            } catch (InvocationTargetException ex) {
                // Unwrap for HandlerExceptionResolvers ...
                Throwable targetException = ex.getTargetException();
                if (targetException instanceof RuntimeException || targetException instanceof Error
                        || targetException instanceof Exception) {
                    ret.setErrorResult(targetException);
                } else {
                    String msg = getInvocationErrorMessage("Failed to invoke controller method", args);
                    ret.setErrorResult(new IllegalStateException(msg, targetException));
                }
            } catch (Exception ex) {
                ret.setErrorResult(ex);
            }
        }
    }).start();

    return ret;
}

From source file:$.ManagerService.java

/**
     * This will download the agent for given device type
     *//from  w  w  w.j av a 2 s  .c om
     * @param deviceName name of the device which is to be created
     * @param sketchType name of sketch type
     * @return agent archive
     */
    @Path("manager/device/{sketch_type}/download")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response downloadSketch(@QueryParam("deviceName") String deviceName,
            @PathParam("sketch_type") String sketchType) {
        try {
            ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName, sketchType);
            Response.ResponseBuilder response = Response.ok(FileUtils.readFileToByteArray(zipFile.getZipFile()));
            response.type("application/zip");
            response.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\"");
            return response.build();
        } catch (IllegalArgumentException ex) {
            return Response.status(400).entity(ex.getMessage()).build();//bad request
        } catch (DeviceManagementException ex) {
            return Response.status(500).entity(ex.getMessage()).build();
        } catch (AccessTokenException ex) {
            return Response.status(500).entity(ex.getMessage()).build();
        } catch (DeviceControllerException ex) {
            return Response.status(500).entity(ex.getMessage()).build();
        } catch (IOException ex) {
            return Response.status(500).entity(ex.getMessage()).build();
        }
    }

From source file:com.smartbear.collab.client.Client.java

public JsonrpcCommandResponse login(String username, String password)
        throws ServerURLException, CredentialsException, Exception {

    JsonrpcCommandResponse result;/*from   www  .j a v a 2  s  .com*/

    List<JsonrpcCommand> methods = new ArrayList<JsonrpcCommand>();
    methods.add(new GetLoginTicket(username, password));
    try {

        JsonrpcResponse response = sendRequest(methods);
        result = response.getResults().get(0);

    } catch (IllegalArgumentException iae) {
        throw new ServerURLException(iae.getMessage());
    } catch (ProcessingException pe) {
        if (pe.getCause().getClass().equals(ConnectException.class)) {
            throw new ServerURLException(pe.getCause().getMessage());
        } else {
            throw new ServerURLException(pe.getMessage());
        }
    } catch (NotFoundException nfe) {
        throw new ServerURLException(nfe.getMessage());
    } catch (Exception e) {
        throw new CredentialsException(e.getMessage());
    }
    if (result.getErrors() == null || result.getErrors().isEmpty()) {
        this.username = username;
        this.ticketId = (String) result.getResult().getValue();
    } else {
        this.username = "";
        this.ticketId = "";
        throw new CredentialsException(result.getErrors().get(0).getMessage());
    }
    return result;
}

From source file:com.github.springtestdbunit.DbUnitTestExecutionListenerPrepareTests.java

@Test
public void shouldFailIfDatabaseConnectionOfWrongTypeIsFound() throws Exception {
    addBean("dbUnitDatabaseConnection", new Integer(0));
    ExtendedTestContextManager testContextManager = new ExtendedTestContextManager(NoDbUnitConfiguration.class);
    try {/* w  w  w .  j  av  a  2s  .  co  m*/
        testContextManager.prepareTestInstance();
    } catch (IllegalArgumentException e) {
        assertEquals("Object of class [java.lang.Integer] must be an instance of interface "
                + "org.dbunit.database.IDatabaseConnection", e.getMessage());
    }
}

From source file:com.pinterest.terrapin.tools.TerrapinAdmin.java

/**
 * Rollback specific file set to last kept version.
 * This function is for command line tool usage.
 *
 * @param args command line arguments containing file set
 * @throws Exception if communication with ZooKeeper fail
 *///  w w  w. j a  v  a 2s .  co m
public void rollbackFileSet(String[] args) throws Exception {
    if (args.length > 1) {
        final String fileSet = args[1];
        FileSetInfo fileSetInfo = lockFileSet(zkManager, fileSet);

        // Add shutdown hook to gracefully catch SIGKILL signal
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    unlockFileSet(zkManager, fileSet);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }));

        try {
            int versionIndex = selectFileSetRollbackVersion(fileSetInfo, System.in);
            if (confirmFileSetRollbackVersion(fileSet, fileSetInfo, versionIndex, System.in)) {
                rollbackFileSet(zkManager, fileSet, fileSetInfo, versionIndex);
            } else {
                System.out.println("exiting rollback...");
            }
        } catch (IllegalArgumentException exception) {
            LOG.error(exception.getMessage());
        }
    } else {
        System.err.println("missing file set argument");
    }
}

From source file:com.linkedin.cubert.functions.builtin.Match.java

private RegexImpl compile(String pattern) {
    RegexImpl impl = null;/*from w ww .  j ava 2 s .c o  m*/
    int regexMethod = determineBestRegexMethod(pattern);
    switch (regexMethod) {
    case 0:
        impl = new CompiledRegex(Pattern.compile(pattern));
        break;
    case 1:
        try {
            impl = new CompiledAutomaton(pattern);
        } catch (IllegalArgumentException e) {
            Log log = LogFactory.getLog(getClass());
            log.debug("Got an IllegalArgumentException for Pattern: " + pattern);
            log.debug(e.getMessage());
            log.debug("Switching to java.util.regex");
            impl = new CompiledRegex(Pattern.compile(pattern));
        }
        break;
    default:
        break;
    }
    return impl;
}

From source file:springfox.documentation.schema.property.OptimizedModelPropertiesProvider.java

private AnnotatedMember safeGetPrimaryMember(BeanPropertyDefinition jacksonProperty) {
    try {// ww  w. j  a va 2 s .  c om
        return jacksonProperty.getPrimaryMember();
    } catch (IllegalArgumentException e) {
        LOG.warn(String.format("Unable to get unique property. %s", e.getMessage()));
        return null;
    }
}

From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderTests.java

@Test
public void testContextLoaderListenerWithUnkownContextInitializer() {
    MockServletContext sc = new MockServletContext("");
    // config file doesn't matter.  just a placeholder
    sc.addInitParameter(PortletContextLoader.CONFIG_LOCATION_PARAM,
            "/org/springframework/web/context/WEB-INF/empty-context.xml");
    sc.addInitParameter(PortletContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM, StringUtils
            .arrayToCommaDelimitedString(new Object[] { UnknownContextInitializer.class.getName() }));
    PortletContextLoaderListener listener = new PortletContextLoaderListener();
    listener.contextInitialized(new ServletContextEvent(sc));

    try {//from w w  w.  j a  v  a  2  s .c  o m
        //initialize the portlet application context, needed because PortletContextLoaderListener.contextInitialized doesn't actually create
        //the portlet app context due to lack of PortletContext reference
        MockPortletContext pc = new MockPortletContext(sc);
        PortletApplicationContextUtils2.getPortletApplicationContext(pc);

        fail("expected exception");
    } catch (IllegalArgumentException ex) {
        assertTrue(ex.getMessage().contains("not assignable"));
    }
}