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:jp.primecloud.auto.zabbix.client.HostgroupClientTest.java

@Test
@Ignore/*  w w w .j  a v  a  2s.com*/
public void testUpdate() {
    // groupid??????
    HostgroupUpdateParam param = new HostgroupUpdateParam();
    param.setName("TestServer");
    try {
        client.hostgroup().update(param);
        fail();
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}

From source file:org.inbio.ait.web.ajax.controller.TaxonomyAutoCompleteController.java

/**
 * Method to get the 10 first specificEpithet that match with the autocomplete query
 * @param request//w  w  w . j  av  a2  s . c  o m
 * @param response
 * @return
 * @throws java.lang.Exception
 */
public ModelAndView specificEpithet(HttpServletRequest request, HttpServletResponse response) throws Exception {

    String param = request.getParameter(queryParam);
    String errorMsj = "No se puede obtener la lista para: " + param + ".";
    List<AutocompleteNode> acnList = new ArrayList<AutocompleteNode>();

    try {
        acnList = taxonomyManager.getElementsByTaxonomicalRange(param,
                TaxonomicalRange.SPECIFICEPITHET.getId());
        return writeReponse(request, response, acnList);

    } catch (IllegalArgumentException iae) {
        throw new Exception(errorMsj + " " + iae.getMessage());
    }
}

From source file:ch.wisv.areafiftylan.teams.controller.TeamRestController.java

@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<?> handleIllegalArgumentException(IllegalArgumentException e) {
    return createResponseEntity(HttpStatus.CONFLICT, e.getMessage());
}

From source file:technology.tikal.gae.http.cache.AbstractCacheController.java

public void manageUpdate() {
    long id = Thread.currentThread().getId();
    if (this.originalData.containsKey(id)) {
        try {/*  w w w  . j av a 2  s. co  m*/
            UpdatePair<T> pair = this.originalData.get(id);
            if (haveChanges(pair)) {
                String uri = getResourseUri(this.currentRequestUri.get(id), CacheAction.UPDATE);
                if (AbstractCacheController.LOGGER.isInfoEnabled()) {
                    AbstractCacheController.LOGGER.info("actualizando el etag:" + uri);
                }
                httpCacheQueryService.updateUriEtagEntry(uri);
            }
        } catch (IllegalArgumentException e) {
            AbstractCacheController.LOGGER.warn("cambio el id de la entidad:" + e.getMessage());
        }
    }
}

From source file:org.opennms.ng.services.trapd.TrapQueueProcessor.java

/**
 * Process a V2 trap and convert it to an event for transmission.
 * //from   w  w w . ja v  a 2s. c o m
 * <p>
 * From RFC2089 ('Mapping SNMPv2 onto SNMPv1'), section 3.3 ('Processing an
 * outgoing SNMPv2 TRAP')
 * </p>
 * 
 * <p>
 * <strong>2b </strong>
 * <p>
 * If the snmpTrapOID.0 value is one of the standard traps the specific-trap
 * field is set to zero and the generic trap field is set according to this
 * mapping:
 * <p>
 * 
 * <pre>
 * 
 *  
 *   
 *    
 *     
 *      
 *            value of snmpTrapOID.0                generic-trap
 *            ===============================       ============
 *            1.3.6.1.6.3.1.1.5.1 (coldStart)                  0
 *            1.3.6.1.6.3.1.1.5.2 (warmStart)                  1
 *            1.3.6.1.6.3.1.1.5.3 (linkDown)                   2
 *            1.3.6.1.6.3.1.1.5.4 (linkUp)                     3
 *            1.3.6.1.6.3.1.1.5.5 (authenticationFailure)      4
 *            1.3.6.1.6.3.1.1.5.6 (egpNeighborLoss)            5
 *       
 *      
 *     
 *    
 *   
 *  
 * </pre>
 * 
 * <p>
 * The enterprise field is set to the value of snmpTrapEnterprise.0 if this
 * varBind is present, otherwise it is set to the value snmpTraps as defined
 * in RFC1907 [4].
 * </p>
 * 
 * <p>
 * <strong>2c. </strong>
 * </p>
 * <p>
 * If the snmpTrapOID.0 value is not one of the standard traps, then the
 * generic-trap field is set to 6 and the specific-trap field is set to the
 * last subid of the snmpTrapOID.0 value.
 * </p>
 * 
 * <p>
 * If the next to last subid of snmpTrapOID.0 is zero, then the enterprise
 * field is set to snmpTrapOID.0 value and the last 2 subids are truncated
 * from that value. If the next to last subid of snmpTrapOID.0 is not zero,
 * then the enterprise field is set to snmpTrapOID.0 value and the last 1
 * subid is truncated from that value.
 * </p>
 * 
 * <p>
 * In any event, the snmpTrapEnterprise.0 varBind (if present) is ignored in
 * this case.
 * </p>
 */
@Override
public Callable<Void> call() {
    try {
        processTrapEvent(((EventCreator) m_trapNotification.getTrapProcessor()).getEvent());
    } catch (IllegalArgumentException e) {
        LOG.info(e.getMessage());
    } catch (Throwable e) {
        LOG.error("Unexpected error processing trap: {}", e, e);
    }
    return null;
}

From source file:com.joyent.manta.http.HttpDownloadContinuationMarker.java

/**
 * Advance the marker's state, updating {@link #currentRange}. Verifies that the next starting offset: 1.
 * non-negative (zero is acceptable because the user may have not read any bytes into the initial request) 2. less
 * than the previous start of the range (the user can't "unread" bytes and move backwards, {@link
 * InputStream#reset()} is not supported by resumable downloads) 3. less than the total number of bytes we expected
 * the user to read (where would those bytes come from?) 4. less than or equal to the end of the target range, this
 * is a restatement of 3 but checks our own math
 *
 * @param totalBytesRead number of bytes read across all resumed responses
 *///from  w w w . j a v a  2s .  co m
void updateRangeStart(final long totalBytesRead) {
    final long nextStartInclusive = this.originalRangeStart + totalBytesRead;

    if (totalBytesRead < 0) {
        throw new IllegalArgumentException(String.format("Bytes read [%d] cannot be negative", totalBytesRead));
    }

    if (nextStartInclusive < this.currentRange.getStartInclusive()) {
        throw new IllegalArgumentException(
                String.format("Next start position [%d] cannot decrease, previously [%d]", nextStartInclusive,
                        this.currentRange.getStartInclusive()));
    }

    if (this.totalRangeSize < totalBytesRead) {
        throw new IllegalArgumentException(
                String.format("Bytes read [%d] cannot be greater than expected number of bytes [%d]",
                        totalBytesRead, this.totalRangeSize));
    }

    if (this.currentRange.getEndInclusive() < nextStartInclusive) {
        throw new IllegalArgumentException(
                String.format("Next start position [%d] cannot be greater than end of range [%d]",
                        nextStartInclusive, this.currentRange.getEndInclusive()));
    }

    final BoundedRequest nextRange;
    try {
        nextRange = new BoundedRequest(nextStartInclusive, this.currentRange.getEndInclusive());
    } catch (final IllegalArgumentException e) {
        throw new IllegalArgumentException("Failed to construct updated HttpRange: " + e.getMessage(), e);
    }

    this.currentRange = nextRange;
}

From source file:org.exist.xquery.modules.jfreechart.JFreeCharting.java

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {

    //was an image and a mime-type speficifed
    if (args[1].isEmpty() || args[2].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }/*w w  w. j  a v  a2s  .c  o  m*/

    try {
        // Get chart type
        String chartType = args[0].getStringValue();

        // Get configuration
        Configuration config = new Configuration();
        config.parse(((NodeValue) args[1].itemAt(0)).getNode());

        // Get datastream
        Serializer serializer = context.getBroker().getSerializer();

        NodeValue node = (NodeValue) args[2].itemAt(0);
        InputStream is = new NodeInputStream(serializer, node);

        // get chart
        JFreeChart chart = null;
        try {
            chart = JFreeChartFactory.createJFreeChart(chartType, config, is);

        } catch (IllegalArgumentException ex) {
            throw new XPathException(this, ex.getMessage());
        }

        // Verify if chart is present
        if (chart == null) {
            throw new XPathException(this, "Unable to create chart '" + chartType + "'");
        }

        Renderer renderer = RendererFactory.getRenderer(config.getImageType());

        // Render output
        if (isCalledAs("render")) {
            byte[] image = renderer.render(chart, config);
            return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(),
                    new ByteArrayInputStream(image));

        } else {
            ResponseWrapper response = getResponseWrapper(context);
            writeToResponseWrapper(config, response, chart, renderer);
        }

    } catch (Exception ex) {
        LOG.error(ex);
        throw new XPathException(this, ex.getMessage());
    }

    return Sequence.EMPTY_SEQUENCE;
}

From source file:android.framework.util.jar.InitManifest.java

private void readName() throws IOException {
    int mark = pos;

    while (pos < buf.length) {
        if (buf[pos++] != ':') {
            continue;
        }/*from  w w w  .j ava2 s  .  c om*/

        String name = new String(buf, mark, pos - mark - 1, Charsets.US_ASCII);

        if (buf[pos++] != ' ') {
            throw new IOException(String.format("Invalid value for attribute '%s'", name));
        }

        try {
            this.name = new Attributes.Name(name);
        } catch (IllegalArgumentException e) {
            // new Attributes.Name() throws IllegalArgumentException but we declare IOException
            throw new IOException(e.getMessage());
        }
        return;
    }
}

From source file:bear.core.Stage.java

private void _validate(List<Address> providedAddresses) {
    try {/*w w w  . j  a  v a2 s.c  om*/
        if (!addresses.containsAll(providedAddresses)) {
            Sets.SetView<Address> missingHosts = Sets.difference(Sets.newHashSet(providedAddresses), addresses);

            throw new StagesException("hosts doesn't exist on stage '" + name + "': "
                    + transform(missingHosts, Functions2.method("getName")));
        }
    } catch (IllegalArgumentException e) {
        throw new StagesException("host doesn't exist on any stage: " + e.getMessage());
    }
}

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

@Test
@Ignore/*www.  j  a va2 s . c o  m*/
public void testDelete() {
    // hostid??????
    try {
        client.host().delete(null);
    } catch (IllegalArgumentException ignore) {
        log.trace(ignore.getMessage());
    }
}