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:it.tidalwave.northernwind.core.impl.filter.MacroFilter.java

@Override
@Nonnull//w ww. jav  a 2  s. com
public String filter(final @Nonnull String text, final @Nonnull String mimeType) {
    final Matcher matcher = pattern.matcher(text);
    final StringBuffer buffer = new StringBuffer();

    while (matcher.find()) {
        final String filtered = doFilter(matcher);
        try {
            matcher.appendReplacement(buffer, filtered);
        } catch (IllegalArgumentException e) // better diagnostics
        {
            throw new IllegalArgumentException(
                    String.format("Pattern error: %s regexp: %s%n**** filtered: %s%n**** buffer: %s",
                            e.getMessage(), pattern.pattern(), filtered, buffer));
        }
    }

    matcher.appendTail(buffer);

    return buffer.toString();
}

From source file:jp.primecloud.auto.zabbix.client.HostClientTest.java

@Test
@Ignore/*from   w w  w  .j  a  v a 2  s  .  c om*/
public void testCreate2() {
    // groups??????
    HostCreateParam param = new HostCreateParam();
    param.setHost("test.scsk.jp");
    try {
        client.host().create(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:jp.primecloud.auto.zabbix.client.HostClientTest.java

@Test
@Ignore//from  w ww.  j  av a  2s  .c o m
public void testUpdate() {
    // hostid??????
    HostUpdateParam param = new HostUpdateParam();
    param.setHost("test.scsk.jp.update");
    try {
        client.host().update(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:com.nec.harvest.controller.KounyuController.java

/**
 * Check purchase date in monthly of table data AT031
 * //  w  ww  .  j a  va 2s  .co m
 * @param orgCode
 * @param monthly
 * @param params
 * @param model
 * @return JsonBean
 */
@RequestMapping(value = "/check/{orgCode:[a-z0-9]+}/{monthly:[\\d]+}", method = RequestMethod.GET)
public @ResponseBody JSONBean checkPurchaseDataMonthly(@PathVariable String orgCode,
        @PathVariable @DateTimeFormat(pattern = "yyyyMM") Date monthly) {
    String processMonthly = DateFormatUtil.format(monthly, DateFormat.DATE_WITHOUT_DAY);
    if (logger.isDebugEnabled()) {
        logger.debug("Checking sales data on month: " + processMonthly + " of organizetion code: " + orgCode);
    }

    try {
        int saleDataOfMonthly = monthlyPurchaseService.findByOrgCodeAndMonth(orgCode, processMonthly);
        if (saleDataOfMonthly > 0) {
            // ????????????????
            return new JSONBean(Boolean.TRUE, "", MessageHelper.get(MsgConstants.CM_CFM_REG_M02));
        } else {
            // ??????????
            return new JSONBean(Boolean.TRUE, "", MessageHelper.get(MsgConstants.CM_CFM_REG_M01));
        }
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    } catch (ServiceException ex) {
        // ???????????
        logger.error(ex.getMessage(), ex);
    }

    return new JSONBean(Boolean.FALSE, "", getSystemError());
}

From source file:jp.primecloud.auto.zabbix.client.HostClientTest.java

@Test
@Ignore// w ww .  j  a  va 2 s.co m
public void testCreate() {
    // host??????
    Hostgroup hostgroup = new Hostgroup();
    hostgroup.setGroupid("4");

    HostCreateParam param = new HostCreateParam();
    param.setGroups(Arrays.asList(hostgroup));
    try {
        client.host().create(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:org.cerberus.servlet.publi.ExecuteNextInQueue.java

/**
 * Executes the next test case represented by the given
 * {@link TestCaseExecutionInQueue}// ww w .  ja  v  a 2s.c  om
 * 
 * @param lastInQueue
 * @param req
 * @param resp
 * @throws IOException
 */
private void executeNext(TestCaseExecutionInQueue lastInQueue, HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    String charset = resp.getCharacterEncoding();
    String query = "";
    try {
        ParamRequestMaker paramRequestMaker = makeParamRequestfromLastInQueue(lastInQueue);
        // TODO : Prefer use mkString(charset) instead of mkString().
        // However the RunTestCase servlet does not decode parameters,
        // then we have to mkString() without using charset
        query = paramRequestMaker.mkString();
    } catch (UnsupportedEncodingException uee) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, uee.getMessage());
        return;
    } catch (IllegalArgumentException iae) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.getMessage());
        return;
    } catch (IllegalStateException ise) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ise.getMessage());
        return;
    }

    CloseableHttpClient httpclient = null;
    HttpGet httpget = null;
    try {
        httpclient = HttpClients.createDefault();
        URI uri = new URIBuilder().setScheme(req.getScheme()).setHost(req.getServerName())
                .setPort(req.getServerPort()).setPath(req.getContextPath() + RunTestCase.SERVLET_URL)
                .setCustomQuery(query).build();
        httpget = new HttpGet(uri);
    } catch (URISyntaxException use) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, use.getMessage());
        return;
    }

    CloseableHttpResponse response = null;
    try {
        response = httpclient.execute(httpget);
        if (response.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) {
            resp.sendError(response.getStatusLine().getStatusCode(),
                    response.getStatusLine().getReasonPhrase());
        }
    } catch (ClientProtocolException cpe) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, cpe.getMessage());
    } finally {
        if (response != null) {
            response.close();
        }
    }

}

From source file:com.carolinarollergirls.scoreboard.jetty.MediaServlet.java

protected void download(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String media = request.getParameter("media");
    String type = request.getParameter("type");

    try {//from  w w  w .  ja  va2  s.com
        URL url = new URL(request.getParameter("url"));
        File typeDir = getTypeDir(media, type, true);
        String name = url.getPath().replaceAll("^([^/]*/)*", "");
        InputStream iS = url.openStream();
        OutputStream oS = new FileOutputStream(new File(typeDir, name));
        IOUtils.copyLarge(iS, oS);
        IOUtils.closeQuietly(iS);
        IOUtils.closeQuietly(oS);

        setTextResponse(response, response.SC_OK, "Successfully downloaded 1 remote file");
    } catch (MalformedURLException muE) {
        setTextResponse(response, response.SC_BAD_REQUEST, muE.getMessage());
    } catch (IllegalArgumentException iaE) {
        setTextResponse(response, response.SC_BAD_REQUEST, iaE.getMessage());
    } catch (FileNotFoundException fnfE) {
        setTextResponse(response, response.SC_BAD_REQUEST, fnfE.getMessage());
    }
}

From source file:org.apache.hadoop.gateway.filter.rewrite.impl.FrontendFunctionProcessorTest.java

@Test
public void testNullHandling() throws Exception {
    UrlRewriteEnvironment badEnv = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
    UrlRewriteEnvironment goodEnv = EasyMock.createNiceMock(UrlRewriteEnvironment.class);
    EasyMock.expect(goodEnv.getAttribute(FrontendFunctionDescriptor.FRONTEND_URI_ATTRIBUTE))
            .andReturn(new URI("http://mock-host:80/mock-root/mock-topo")).anyTimes();
    EasyMock.replay(badEnv, goodEnv);//from   ww  w .  jav a 2 s .com

    FrontendFunctionProcessor processor = new FrontendFunctionProcessor();
    try {
        processor.initialize(null, null);
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("environment"));
    }
    try {
        processor.initialize(badEnv, null);
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("org.apache.hadoop.knox.frontend.context.uri"));
    }
    processor.initialize(goodEnv, null);
    processor.resolve(null, null);
}

From source file:com.carolinarollergirls.scoreboard.jetty.MediaServlet.java

protected void remove(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String media = request.getParameter("media");
    String type = request.getParameter("type");
    String filename = request.getParameter("filename");

    try {/*from  w  ww .  j a v  a 2s.  c  om*/
        File typeDir = getTypeDir(media, type, false);
        File f = new File(typeDir, filename);
        String path = f.getAbsolutePath();

        if (!f.exists())
            setTextResponse(response, response.SC_BAD_REQUEST, "File does not exist : " + path);
        else if (f.isDirectory())
            setTextResponse(response, response.SC_BAD_REQUEST, "Path is a directory : " + path);
        else if (!f.delete())
            setTextResponse(response, response.SC_BAD_REQUEST, "Could not delete file " + path);
        else
            setTextResponse(response, response.SC_OK, "Successfully removed " + path);
    } catch (IllegalArgumentException iaE) {
        setTextResponse(response, response.SC_BAD_REQUEST, iaE.getMessage());
    } catch (FileNotFoundException fnfE) {
        setTextResponse(response, response.SC_BAD_REQUEST, fnfE.getMessage());
    }
}

From source file:ch.cyberduck.core.threading.BackgroundException.java

public BackgroundException(Host host, Path path, String message, Throwable cause) {
    super(cause);
    this.host = host;
    this.path = path;
    if (null == message) {
        this.message = Locale.localizedString("Unknown");
    } else if (null == path) {
        this.message = StringUtils.chomp(message);
    } else {//from w  w  w . j a  v  a  2s. co m
        try {
            this.message = MessageFormat.format(StringUtils.chomp(message), path.getName());
        } catch (IllegalArgumentException e) {
            log.warn(String.format("Error parsing message with format %s", e.getMessage()));
            this.message = StringUtils.chomp(message);
        }
    }
}