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.DarkTimeAnalysis.java

private boolean showDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);//from   w  w  w .  ja  v  a2s .c  om

    gd.addMessage("Compute the cumulative dark-time histogram");
    ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);

    gd.addChoice("Method", METHOD, METHOD[method]);
    gd.addSlider("Search_distance (nm)", 5, 150, searchDistance);
    gd.addNumericField("Max_dark_time (seconds)", maxDarkTime, 2);
    gd.addSlider("Percentile", 0, 100, percentile);
    gd.addSlider("Histogram_bins", 0, 100, nBins);
    gd.showDialog();

    if (gd.wasCanceled())
        return false;

    inputOption = gd.getNextChoice();
    method = gd.getNextChoiceIndex();
    searchDistance = gd.getNextNumber();
    maxDarkTime = gd.getNextNumber();
    percentile = gd.getNextNumber();
    nBins = (int) Math.abs(gd.getNextNumber());

    // Check arguments
    try {
        Parameters.isAboveZero("Search distance", searchDistance);
        Parameters.isPositive("Percentile", percentile);
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return false;
    }

    return true;
}

From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java

public void setGraph() {
    HistogramChartDataset personDataset = null;
    HistogramChartDataset itemData = null;

    try {//  www.  ja  va  2s  . c  om
        //get titles
        String chartTitle = command.getFreeOption("title").getString();
        String chartSubtitle = command.getFreeOption("subtitle").getString();
        PlotOrientation itemMapOrientation = PlotOrientation.HORIZONTAL;

        //create common x-axis
        NumberAxis domainAxis = new NumberAxis();
        domainAxis.setLabel("Logits");

        //create histogram
        personDataset = new HistogramChartDataset();
        ValueAxis rangeAxis = new NumberAxis("Person Density");
        if (itemMapOrientation == PlotOrientation.HORIZONTAL)
            rangeAxis.setInverted(true);
        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        renderer.setURLGenerator(new StandardXYURLGenerator());
        renderer.setDrawBarOutline(true);
        renderer.setShadowVisible(false);
        XYPlot personPlot = new XYPlot(personDataset, null, rangeAxis, renderer);
        personPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //create scatterplot of item difficulty
        itemData = new HistogramChartDataset();
        NumberAxis itemRangeAxis = new NumberAxis("Item Frequency");
        if (itemMapOrientation == PlotOrientation.VERTICAL) {
            itemRangeAxis.setInverted(true);
        }

        XYBarRenderer itemRenderer = new XYBarRenderer();
        itemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        itemRenderer.setURLGenerator(new StandardXYURLGenerator());
        itemRenderer.setDrawBarOutline(true);
        itemRenderer.setShadowVisible(false);
        XYPlot itemPlot = new XYPlot(itemData, null, itemRangeAxis, itemRenderer);
        itemPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //combine the two charts
        CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
        cplot.add(personPlot, 3);
        cplot.add(itemPlot, 2);
        cplot.setGap(8.0);
        cplot.setDomainGridlinePaint(Color.white);
        cplot.setDomainGridlinesVisible(true);
        cplot.setOrientation(itemMapOrientation);

        //            //next four lines are temp setting for book
        //            //these four lines will create a histogram with white bars so it appears as just the bar outline
        //            renderer.setBarPainter(new StandardXYBarPainter());
        //            renderer.setSeriesPaint(0, Color.white);
        //            itemRenderer.setBarPainter(new StandardXYBarPainter());
        //            itemRenderer.setSeriesPaint(0, Color.white);

        chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
        chart.setBackgroundPaint(Color.white);
        if (chartSubtitle != null && !"".equals(chartSubtitle)) {
            chart.addSubtitle(new TextTitle(chartSubtitle));
        }

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

        //            //temp setting for book
        //            this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

        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:edu.vt.middleware.crypt.AbstractCli.java

/**
 * Parses command line options and invokes the proper handler to perform the
 * requested action, or the default action if no action is specified.
 *
 * @param  args  Command line arguments.
 *///from w  w w .  j  av  a2s. c o  m
public final void performAction(final String[] args) {
    initOptions();
    try {
        if (args.length > 0) {
            final CommandLineParser parser = new GnuParser();
            final CommandLine line = parser.parse(options, args);
            if (line.hasOption(OPT_EXAMPLE)) {
                printExamples();
            } else {
                dispatch(line);
            }
        } else {
            printHelp();
        }
    } catch (ParseException pex) {
        System.err.println("Failed parsing command arguments: " + pex.getMessage());
    } catch (IllegalArgumentException iaex) {
        String msg = "Operation failed: " + iaex.getMessage();
        if (iaex.getCause() != null) {
            msg += " Underlying reason: " + iaex.getCause().getMessage();
        }
        System.err.println(msg);
    } catch (Exception ex) {
        System.err.println("Operation failed:");
        ex.printStackTrace(System.err);
    }
}

From source file:eu.europa.ec.fisheries.uvms.exchange.dao.bean.ExchangeLogDaoBean.java

@Override
public List<ExchangeLog> getExchangeLogListPaginated(Integer page, Integer listSize, String sql,
        List<SearchValue> searchKeyValues) throws ExchangeDaoException {
    try {/*  ww  w. j  a va 2 s  .c  o  m*/
        LOG.debug("SQL QUERY IN LIST PAGINATED: " + sql);
        TypedQuery<ExchangeLog> query = em.createQuery(sql, ExchangeLog.class);

        HashMap<ExchangeSearchField, List<SearchValue>> orderedValues = SearchFieldMapper
                .combineSearchFields(searchKeyValues);

        setQueryParameters(query, orderedValues);

        query.setFirstResult(listSize * (page - 1));
        query.setMaxResults(listSize);

        return query.getResultList();
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error getting exchangelog list paginated ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting list ] ");
    } catch (Exception e) {
        LOG.error("[ Error getting exchangelog list paginated ]  {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting list ] ");
    }
}

From source file:ste.web.http.beanshell.BugFreeBeanShellHandler.java

@Test
public void constructors() throws Exception {
    try {//from   w ww . j av  a 2  s  . co  m
        new BeanShellHandler(null);
        fail("missing check for null parameters");
    } catch (IllegalArgumentException x) {
        then(x.getMessage()).contains("webroot").contains("not be null");
    }

    BeanShellHandler h = new BeanShellHandler(new File(ROOT).getAbsolutePath());
    then(h.getControllersFolder()).isNull();

    h = new BeanShellHandler(new File(ROOT).getAbsolutePath(), "/c");
    then(h.getControllersFolder()).isEqualTo("/c");

    h = new BeanShellHandler(new File(ROOT).getAbsolutePath(), null);
    then(h.getControllersFolder()).isNull();

    h = new BeanShellHandler(new File(ROOT).getAbsolutePath(), "/a");
    then(h.getControllersFolder()).isEqualTo("/a");
}

From source file:eu.dime.userresolver.service.user.UserService.java

@DELETE
@Produces("application/json")
public Response remove2(@QueryParam("said") String said) {
    try {/* w w  w. ja v  a 2s .co  m*/
        RegisterResponse registerResponse = new RegisterResponse();

        User user = userProvider.remove(said);
        registerResponse.result = user;

        return Response.ok(registerResponse).build();
    } catch (IllegalArgumentException e) {
        return Response.ok(new ErrorResponse(e.getMessage())).status(Response.Status.NOT_FOUND).build();
    } catch (IllegalStateException e) {
        return Response.ok(new ErrorResponse(e.getMessage())).status(Response.Status.INTERNAL_SERVER_ERROR)
                .build();
    }
}

From source file:eu.europa.ec.fisheries.uvms.exchange.dao.bean.ExchangeLogDaoBean.java

@Override
public List<ExchangeLogStatus> getExchangeLogStatusHistory(String sql, ExchangeHistoryListQuery searchQuery)
        throws ExchangeDaoException {
    try {//from   w  w w .j  a va  2 s  . c  o m
        LOG.debug("SQL query for status history " + sql);
        TypedQuery<ExchangeLogStatus> query = em.createQuery(sql, ExchangeLogStatus.class);
        if (searchQuery.getStatus() != null && !searchQuery.getStatus().isEmpty()) {
            query.setParameter("status", searchQuery.getStatus());
        }
        if (searchQuery.getType() != null && !searchQuery.getType().isEmpty()) {
            query.setParameter("type", searchQuery.getType());
        }
        if (searchQuery.getTypeRefDateFrom() != null) {
            Date from = searchQuery.getTypeRefDateFrom();
            query.setParameter("from", from);
        }
        if (searchQuery.getTypeRefDateTo() != null) {
            Date to = searchQuery.getTypeRefDateTo();
            query.setParameter("to", to);
        }
        return query.getResultList();
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error getting exchangelog status list ] " + e.getMessage());
        throw new ExchangeDaoException("[ Error when getting search list ] ");
    } catch (Exception e) {
        LOG.error("[ Error getting exchangelog status list " + e.getMessage());
        throw new ExchangeDaoException("[ Error when getting search list ] ");
    }
}

From source file:org.apache.arrow.tools.TestIntegration.java

@Test
public void testInvalid() throws Exception {
    File testValidInFile = testFolder.newFile("testValidIn.arrow");
    File testInvalidInFile = testFolder.newFile("testInvalidIn.arrow");
    File testJSONFile = testFolder.newFile("testInvalidOut.json");
    testJSONFile.delete();/*from w  w w  .j  a v  a  2s .com*/

    // generate an arrow file
    writeInput(testValidInFile, allocator);
    // generate a different arrow file
    writeInput2(testInvalidInFile, allocator);

    Integration integration = new Integration();

    // convert the "valid" file to json
    String[] args1 = { "-arrow", testValidInFile.getAbsolutePath(), "-json", testJSONFile.getAbsolutePath(),
            "-command", Command.ARROW_TO_JSON.name() };
    integration.run(args1);

    // compare the "invalid" file to the "valid" json
    String[] args3 = { "-arrow", testInvalidInFile.getAbsolutePath(), "-json", testJSONFile.getAbsolutePath(),
            "-command", Command.VALIDATE.name() };
    // this should fail
    try {
        integration.run(args3);
        fail("should have failed");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage(), e.getMessage().contains("Different values in column"));
        assertTrue(e.getMessage(), e.getMessage().contains("999"));
    }

}

From source file:eu.dime.userresolver.service.user.UserService.java

@POST
@Path("/remove")
@Produces("application/json")
public Response remove(@QueryParam("said") String said) {
    try {// ww w .j  a  va2s .  c o  m
        RegisterResponse registerResponse = new RegisterResponse();

        User user = userProvider.remove(said);
        registerResponse.result = user;

        return Response.ok(registerResponse).build();
    } catch (IllegalArgumentException e) {
        return Response.ok(new ErrorResponse(e.getMessage())).status(Response.Status.NOT_FOUND).build();
    } catch (IllegalStateException e) {
        return Response.ok(new ErrorResponse(e.getMessage())).status(Response.Status.INTERNAL_SERVER_ERROR)
                .build();
    }
}

From source file:edu.depaul.armada.dao.ContainerDaoTest.java

/**
 * Test method for {@link edu.depaul.armada.dao.ContainerDao#store(java.lang.Object)}.
 *///from   ww w . j  ava2 s .  com
@DirtiesContext
@Test
public void testStore() {

    try {
        dao.store(null);
        fail("Expected IllegalArgumentException!");
    } catch (IllegalArgumentException iae) {
        assertEquals("Container instance cannot be null!", iae.getMessage());
    }

    Container container = TestUtil.newContainer();
    dao.store(container);

    List<Container> containers = dao.getAll();

    assertEquals(1, containers.size());
}