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:gdsc.smlm.ij.plugins.ImageBackground.java

private int showDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);/*from w  ww .  j ava  2  s.c o  m*/

    gd.addMessage("Creates a background and mask image from a sample input stack\nusing a median projection");

    gd.addNumericField("Bias", bias, 0);
    gd.addSlider("Blur", 0, 20, sigma);

    gd.showDialog();

    if (gd.wasCanceled())
        return DONE;

    bias = (float) gd.getNextNumber();
    sigma = gd.getNextNumber();

    // Check arguments
    try {
        Parameters.isPositive("Bias", bias);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return DONE;
    }

    return flags;
}

From source file:com.realdolmen.rdfleet.webmvc.controllers.fleet.EmployeeCarManagementController.java

@RequestMapping(value = "/status-in-use", method = RequestMethod.POST)
public String setCarStatusInUse(@RequestParam("employeeId") Long employeeId,
        @RequestParam("licensePlate") String licensePlate, Model model) {
    if (employeeId == null) {
        model.addAttribute("error", "Employee id must be given.");
    }// www  .j  a  v  a2  s . c o m

    RdEmployee employee = employeeService.findRdEmployee(employeeId);

    if (employee == null) {
        model.addAttribute("error", "Employee was not found.");
        return "fleet/employee.list";
    }

    try {
        employeeService.setEmployeeCarInUse(employee, licensePlate);
    } catch (IllegalArgumentException e) {
        model.addAttribute("error", e.getMessage());
    }

    if (model.containsAttribute("error")) {
        model.addAttribute("employee", employee);
        return "fleet/employee.car.detail";
    }

    return "redirect:" + fromMappingName("ECMC#viewEmployeeCar").arg(0, employee.getId()).build();
}

From source file:org.synyx.hades.dao.orm.support.GenericDaoFactoryBeanUnitTest.java

/**
 * Asserts that the factory recognized configured DAO classes that contain
 * custom method but no custom implementation could be found. Furthremore
 * the exception has to contain the name of the DAO interface as for a large
 * DAO configuration it's hard to find out where this error occured.
 * //from w  ww  . j av a 2 s  .  c o m
 * @throws Exception
 */
@Test
public void capturesMissingCustomImplementationAndProvidesInterfacename() throws Exception {

    GenericDaoFactoryBean<SampleDao> factory = GenericDaoFactoryBean.create(SampleDao.class, entityManager);

    try {
        factory.afterPropertiesSet();
        fail("Expected IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains(SampleDao.class.getName()));
    }
}

From source file:com.coroptis.coidi.rp.services.impl.DiscoverySupportImpl.java

@Override
public DiscoveryResult getXrdsDocument(final String xrdsDocumentUrl, final String claimedId)
        throws AuthenticationProcessException {
    try {//from  w w w  .  j  ava  2  s  .  c  om
        if (logger.isDebugEnabled()) {
            logger.debug("trying to get at: " + xrdsDocumentUrl);
        }
        HttpGet httpget = new HttpGet(xrdsDocumentUrl);
        httpget.setHeader("Accept", "application/xrds+xml");
        HttpResponse resp = httpService.getHttpClient().execute(httpget);
        DiscoveryResult out = xrdsService.extractDiscoveryResult(EntityUtils.toString(resp.getEntity()));
        out.setClaimedId(claimedId);
        return out;
    } catch (IllegalArgumentException e) {
        logger.error(e.getMessage(), e);
        throw new AuthenticationProcessException("Invalid format of you identificator");
    } catch (ClientProtocolException e) {
        logger.error(e.getMessage(), e);
        throw new AuthenticationProcessException(
                "There is problem to get XRDS document, check your identificator");
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new AuthenticationProcessException(
                "There is problem to get XRDS document, check your identificator");
    }
}

From source file:com.itemanalysis.jmetrik.graph.scatterplot.ScatterplotPanel.java

public void setGraph() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    try {//from www  . ja va2s.  com
        chart = ChartFactory.createScatterPlot(title, // chart title
                xlabel, // x axis label
                ylabel, // y axis label
                dataset, // data
                orientation, showLegend, // include legend
                true, // tooltips
                false // urls
        );

        if (subtitle != null && !"".equals(subtitle)) {
            TextTitle subtitle1 = new TextTitle(subtitle);
            chart.addSubtitle(subtitle1);
        }

        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setNoDataMessage("NO DATA");
        plot.setDomainZeroBaselineVisible(false);
        plot.setRangeZeroBaselineVisible(false);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

        ChartPanel panel = new ChartPanel(chart);
        panel.getPopupMenu().addSeparator();
        this.addJpgMenuItem(this, panel.getPopupMenu());
        panel.setPreferredSize(new Dimension(width, height));

        chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
        this.setBackground(Color.WHITE);
        this.add(panel);

    } catch (IllegalArgumentException ex) {
        logger.fatal(ex.getMessage(), ex);
        this.firePropertyChange("error", "", "Error - Check log for details.");
    }
}

From source file:org.synyx.hades.dao.orm.support.GenericDaoFactoryUnitTest.java

/**
 * Asserts that the factory recognized configured DAO classes that contain
 * custom method but no custom implementation could be found. Furthremore
 * the exception has to contain the name of the DAO interface as for a large
 * DAO configuration it's hard to find out where this error occured.
 * /*from w w w .  j a  v  a 2s.c  o m*/
 * @throws Exception
 */
@Test
public void capturesMissingCustomImplementationAndProvidesInterfacename() throws Exception {

    try {
        factory.getDao(SampleDao.class);
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains(SampleDao.class.getName()));
    }
}

From source file:org.artifactory.rest.resource.search.types.PatternSearchResource.java

@GET
@Produces({ SearchRestConstants.MT_PATTERN_SEARCH_RESULT, MediaType.APPLICATION_JSON })
public PatternResultFileSet get(@QueryParam(SearchRestConstants.PARAM_PATTERN) String pattern)
        throws IOException {
    if (!authorizationService.isAuthenticated() || authorizationService.isAnonymous()) {
        throw new AuthorizationRestException();
    }//w w  w  .java2s.  c om
    try {
        return search(pattern);
    } catch (IllegalArgumentException iae) {
        throw new BadRequestException(iae.getMessage());
    } catch (MissingRestAddonException mrae) {
        throw mrae;
    } catch (TimeoutException te) {
        String secs = ConstantValues.searchPatternTimeoutSecs.getString();
        log.error("Artifacts pattern search timeout: artifactory.search.pattern.timeoutSecs={}.", secs);
        throw new RestException(HttpStatus.SC_REQUEST_TIMEOUT,
                "Artifacts pattern search returned 0 results because it " + "exceeded the configured timeout ("
                        + secs + " seconds). Please make sure your query is not too "
                        + "broad, causing the search to scan too many nodes, or ask your Artifactory administrator to "
                        + "change the default timeout.");
    } catch (Exception e) {
        String errorMessage = String.format(
                "Error occurred while searching for artifacts matching the pattern '%s': %s", pattern,
                e.getMessage());
        log.error(errorMessage, e);
        throw new RestException(errorMessage);
    }
}

From source file:com.couchbase.client.spring.cache.wiring.AbstractCouchbaseCacheWiringTest.java

@Test
public void testCacheableMethodWithUnknownCacheNameFails() {
    try {//from  w w w .ja  va  2  s  .  c o  m
        service.getDataWrongCache("criteria");
        fail("Cacheable method with unknown cache name expected to fail");
    } catch (IllegalArgumentException e) {
        if (e.getMessage() == null || !e.getMessage().contains("Cannot find cache named 'wrongCache'")) {
            fail("Expected IllegalArgumentException to state it cannot find cache named 'wrongCache'");
        }
    }
}

From source file:de.otto.jsonhome.registry.controller.RegistryJsonHomeController.java

@RequestMapping(value = "/json-home", produces = { "application/json" })
@ResponseBody/*w  w w.  jav a  2s . c o m*/
public Map<String, ?> getAsApplicationJson(
        @RequestParam(required = false) @Doc(value = "The name of the json-home registry.") final String registry,
        final HttpServletResponse response) {
    LOG.info("Returning json-home in application/json format.");
    // home document should be cached:
    response.setHeader("Cache-Control", "max-age=" + maxAge);
    response.setHeader("Vary", "Accept");
    try {
        final String selectedRegistry = registry != null ? registry : defaultRegistry;
        return toRepresentation(jsonHomeSource.getJsonHome(selectedRegistry), APPLICATION_JSON);
    } catch (final IllegalArgumentException e) {
        try {
            response.sendError(SC_NOT_FOUND, e.getMessage());
        } catch (IOException ignore) {
        }
        throw e;
    }
}

From source file:org.apache.camel.component.http4.HttpsTwoDifferentSslContextParametersGetTest.java

@Test
public void httpsTwoDifferentSSLContextNotSupported() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override/* w  w w . j av a2 s  . c  om*/
        public void configure() throws Exception {
            from("direct:foo").to("https4://127.0.0.1:" + getPort()
                    + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParametersRef=sslContextParameters");

            from("direct:bar").to("https4://127.0.0.1:" + getPort()
                    + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParametersRef=sslContextParameters2");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = (IllegalArgumentException) e.getCause().getCause();
        assertNotNull(iae);
        assertTrue(iae.getMessage().startsWith("Only same instance of SSLContextParameters is supported."));
    }
}