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:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportComponent().//from  w  w  w  .  j  a v  a  2  s  .c  o  m
 *
 * @param exportable
 * @param filename
 * @param timestamp
 * @param type
 * @param width
 * @param height
 * @param log
 * @param clock
 *
 * @return boolean
 */

public static boolean exportComponent(final ExportableComponentInterface exportable, final String filename,
        final boolean timestamp, final String type, final int width, final int height, final Vector<Vector> log,
        final ObservatoryClockInterface clock) {
    final String SOURCE = "DataExporter.exportComponent()";
    boolean boolSuccess;

    //        String[] arrayNames = ImageIO.getWriterFormatNames();
    //
    //        for (int i = 0;
    //             i < arrayNames.length;
    //             i++)
    //            {
    //            String arrayName = arrayNames[i];
    //            System.out.println("DataExporter.exportComponent() FORMAT NAME=" + arrayName);
    //            }
    //
    boolSuccess = false;

    if ((exportable != null) && (filename != null) && (!EMPTY_STRING.equals(filename)) && (type != null)
            && (!EMPTY_STRING.equals(type)) && (log != null) && (clock != null)
            && (Arrays.asList(ImageIO.getWriterFormatNames()).contains(type))) {
        try {
            final File file;
            final int intRealWidth;
            final int intRealHeight;

            file = new File(FileUtilities.buildFullFilename(filename, timestamp, type));
            FileUtilities.overwriteFile(file);

            intRealWidth = width;
            intRealHeight = height;

            // Support all current formats
            if ((FileUtilities.png.equalsIgnoreCase(type)) || (FileUtilities.jpg.equalsIgnoreCase(type))
                    || (FileUtilities.gif.equalsIgnoreCase(type))) {
                BufferedImage buffer;
                final Graphics2D graphics2D;

                LOGGER.debugTimedEvent(LOADER_PROPERTIES.isTimingDebug(),
                        "DataExporter.exportComponent() writing [file " + file.getAbsolutePath() + "] [width="
                                + intRealWidth + "] [height=" + intRealHeight + "]");

                buffer = new BufferedImage(intRealWidth, intRealHeight, BufferedImage.TYPE_INT_RGB);

                // Create a graphics context on the buffered image
                graphics2D = buffer.createGraphics();

                // Draw on the image
                graphics2D.clearRect(0, 0, intRealWidth, intRealHeight);
                exportable.paintForExport(graphics2D, intRealWidth, intRealHeight);

                // Export the image
                ImageIO.write(buffer, type, file);
                graphics2D.dispose();
                boolSuccess = true;

                SimpleEventLogUIComponent
                        .logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
                // Help the GC?
                buffer = null;

                ObservatoryInstrumentHelper.runGarbageCollector();
            } else {
                SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_COMPONENT
                        + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_INVALID_FORMAT + TERMINATOR, SOURCE,
                        clock);
            }
        }

        catch (IllegalArgumentException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT
                            + EXCEPTION_PARAMETER_INVALID + TERMINATOR + SPACE + METADATA_EXCEPTION
                            + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_COMPONENT + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_COMPONENT
                + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_COMPONENT + TERMINATOR, SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:net.opentsdb.tsd.GraphHandler.java

/** Parses the {@code wxh} query parameter to set the graph dimension. */
static void setPlotDimensions(final HttpQuery query, final Plot plot) {
    final String wxh = query.getQueryStringParam("wxh");
    if (wxh != null && !wxh.isEmpty()) {
        final int wxhlength = wxh.length();
        if (wxhlength < 7) { // 100x100 minimum.
            throw new BadRequestException("Parameter wxh too short: " + wxh);
        }/*from  www. j  ava  2  s .c  o  m*/
        final int x = wxh.indexOf('x', 3); // Start at 2 as min size is 100x100
        if (x < 0) {
            throw new BadRequestException("Invalid wxh parameter: " + wxh);
        }
        try {
            final short width = Short.parseShort(wxh.substring(0, x));
            final short height = Short.parseShort(wxh.substring(x + 1, wxhlength));
            try {
                plot.setDimensions(width, height);
            } catch (IllegalArgumentException e) {
                throw new BadRequestException("Invalid wxh parameter: " + wxh + ", " + e.getMessage());
            }
        } catch (NumberFormatException e) {
            throw new BadRequestException("Can't parse wxh '" + wxh + "': " + e.getMessage());
        }
    }
}

From source file:io.syndesis.rest.v1.handler.exception.IllegalArgumentExceptionMapper.java

@Override
protected String developerMessage(IllegalArgumentException exception) {
    return "Illegal Argument on Call " + exception.getMessage();
}

From source file:com.exxonmobile.ace.hybris.core.actions.B2BAcceleratorInformOfOrderApprovalRejection.java

@Override
public void executeAction(final B2BApprovalProcessModel process) throws RetryLaterException {
    try {/*from  w  ww  .j a  va 2  s . c  o m*/
        final OrderModel order = process.getOrder();
        Assert.notNull(order,
                String.format("Order of BusinessProcess %s should have be set for accelerator", process));
        if (LOG.isDebugEnabled()) {
            LOG.debug(String.format("Process for accelerator: %s in step %s order: %s user: %s ",
                    process.getCode(), getClass(), order.getUnit(), order.getUser().getUid()));
        }
    } catch (final IllegalArgumentException e) {
        LOG.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.bofa.sstradingreport.support.ExceptionHandlerAdvice.java

@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<String> handleIllegalArgumentException(IllegalArgumentException e) throws Exception {
    return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}

From source file:br.ime.usp.aztec.aztdis.AZTDISMain.java

@Override
public void run(String[] algorithmArgs) throws IOException {
    AZTDISCommandLineParametersParser parametersParser = new AZTDISCommandLineParametersParser();
    try {//from ww  w  .  ja va2s .  c om
        AZTDISParameters parameters = parametersParser.parse(algorithmArgs);
        new AZTDIS().encode(parameters);
        parameters.getOutput().close();
    } catch (IllegalArgumentException e) {
        System.err.println(e.getMessage());
        parametersParser.printHelp();
        System.exit(1);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        parametersParser.printHelp();
        System.exit(1);
    } catch (PleaseHelpMeException e) {
        parametersParser.printHelp();
    }
}

From source file:org.jasig.cas.client.validation.Cas10TicketValidationFilterTests.java

@Test
public void testThrowsRenewInitParam() throws Exception {
    final Cas10TicketValidationFilter f = new Cas10TicketValidationFilter();
    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerUrlPrefix", "https://cas.example.com");
    config.addInitParameter("renew", "true");
    try {//from w w  w . j  ava  2  s . c  o  m
        f.init(config);
        fail("Should have thrown IllegalArgumentException.");
    } catch (final IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Renew MUST"));
    }
}

From source file:org.jasig.cas.client.validation.Saml11TicketValidationFilterTests.java

@Test
public void testRenewInitParamThrows() throws Exception {
    final Saml11TicketValidationFilter f = new Saml11TicketValidationFilter();
    final MockFilterConfig config = new MockFilterConfig();
    config.addInitParameter("casServerUrlPrefix", "https://cas.example.com");
    config.addInitParameter("renew", "true");
    try {/*from ww w .j  ava2 s  .  com*/
        f.init(config);
        fail("Should have thrown IllegalArgumentException.");
    } catch (final IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Renew MUST"));
    }
}

From source file:com.itemanalysis.jmetrik.graph.linechart.LineChartPanel.java

private void processCommand() {
    try {//www  .j  a  v  a2  s . c  o  m
        title = command.getFreeOption("title").getString();
        subtitle = command.getFreeOption("subtitle").getString();
        xlabel = command.getFreeOption("xvar").getString();
        ylabel = command.getFreeOption("yvar").getString();
        setLineChart(title, subtitle, xlabel, ylabel);

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

From source file:com.itemanalysis.jmetrik.graph.density.DensityPanel.java

private void processCommand() {
    try {/*from w w  w  .  j a va  2 s  .c  om*/
        title = command.getFreeOption("title").getString();
        xlabel = command.getFreeOption("variable").getString();
        ylabel = "Density";
        setLineChart(title, subtitle, xlabel, ylabel);

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