Example usage for java.lang IllegalArgumentException getCause

List of usage examples for java.lang IllegalArgumentException getCause

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.schemaspy.Config.java

public List<String> getRemainingParameters() {
    try {//  w w w . j a  va 2s  .c  o m
        populate();
    } catch (IllegalArgumentException exc) {
        throw new InvalidConfigurationException(exc);
    } catch (IllegalAccessException exc) {
        throw new InvalidConfigurationException(exc);
    } catch (InvocationTargetException exc) {
        if (exc.getCause() instanceof InvalidConfigurationException)
            throw (InvalidConfigurationException) exc.getCause();
        throw new InvalidConfigurationException(exc.getCause());
    } catch (IntrospectionException exc) {
        throw new InvalidConfigurationException(exc);
    }

    return options;
}

From source file:org.apache.pulsar.functions.worker.rest.api.FunctionsImpl.java

@DELETE
@Path("/{tenant}/{namespace}/{functionName}")
public Response deregisterFunction(final @PathParam("tenant") String tenant,
        final @PathParam("namespace") String namespace, final @PathParam("functionName") String functionName) {

    // validate parameters
    try {//from w w  w .  j  a v a 2  s  .c o m
        validateDeregisterRequestParams(tenant, namespace, functionName);
    } catch (IllegalArgumentException e) {
        log.error("Invalid deregister function request @ /{}/{}/{}", tenant, namespace, functionName, e);
        return Response.status(Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON)
                .entity(new ErrorData(e.getMessage())).build();
    }

    FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();
    if (!functionMetaDataManager.containsFunction(tenant, namespace, functionName)) {
        log.error("Function to deregister does not exist @ /{}/{}/{}", tenant, namespace, functionName);
        return Response.status(Status.NOT_FOUND).type(MediaType.APPLICATION_JSON)
                .entity(new ErrorData(String.format("Function %s doesn't exist", functionName))).build();
    }

    CompletableFuture<RequestResult> completableFuture = functionMetaDataManager.deregisterFunction(tenant,
            namespace, functionName);

    RequestResult requestResult = null;
    try {
        requestResult = completableFuture.get();
        if (!requestResult.isSuccess()) {
            return Response.status(Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON)
                    .entity(new ErrorData(requestResult.getMessage())).build();
        }
    } catch (ExecutionException e) {
        log.error("Execution Exception while deregistering function @ /{}/{}/{}", tenant, namespace,
                functionName, e);
        return Response.serverError().type(MediaType.APPLICATION_JSON)
                .entity(new ErrorData(e.getCause().getMessage())).build();
    } catch (InterruptedException e) {
        log.error("Interrupted Exception while deregistering function @ /{}/{}/{}", tenant, namespace,
                functionName, e);
        return Response.status(Status.REQUEST_TIMEOUT).type(MediaType.APPLICATION_JSON).build();
    }

    return Response.status(Status.OK).entity(requestResult.toJson()).build();
}

From source file:jp.terasoluna.fw.beans.JXPathIndexedBeanWrapperImplTest01.java

/**
 * testGetIndexedPropertyValuesMap16() <br>
 * <br>/*from  www  .j  a v a 2 s  .c  o m*/
 * () <br>
 * G <br>
 * <br>
 * () propertyName:aa(aa.bb<br>
 * () this.context:Map<String, Object><br>
 * ?Map<br>
 * <br>
 * () :IllegalArgumentException<br>
 * Invalid property name. PropertyName: 'aa(aa.bbb'XPath: '/aa(aa/bbb'<br>
 * () :<br>
 * Invalid property name. PropertyName: 'aa(aa.bbb'XPath: '/aa(aa/bbb'<br>
 * <br>
 * ?Map?<br>
 * ??Map? <br>
 * @throws Exception ?????
 */
@Test
public void testGetIndexedPropertyValuesMap16() throws Exception {
    // ??
    JXPathIndexedBeanWrapperImpl bw = new JXPathIndexedBeanWrapperImpl(new HashMap<String, Object>());

    // 
    try {
        bw.getIndexedPropertyValues("aa(aa.bbb");
        fail();
    } catch (IllegalArgumentException e) {
        // OK
        String expect = "Invalid property name. PropertyName: 'aa(aa.bbb'XPath: '/aa(aa/bbb'";
        assertEquals(expect, e.getMessage());
        assertSame(JXPathInvalidSyntaxException.class, e.getCause().getClass());
    }
}

From source file:jp.terasoluna.fw.beans.JXPathIndexedBeanWrapperImplTest01.java

/**
 * testGetIndexedPropertyValuesMap17() <br>
 * <br>/*from  w w w .j a  v  a  2s .co m*/
 * () <br>
 * G <br>
 * <br>
 * () propertyName:aa)aa.bb<br>
 * () this.context:Map<String, Object><br>
 * ?Map<br>
 * <br>
 * () :IllegalArgumentException<br>
 * Invalid property name. PropertyName: 'aa)aa.bbb'XPath: '/aa)aa/bbb'<br>
 * () :<br>
 * Invalid property name. PropertyName: 'aa)aa.bbb'XPath: '/aa)aa/bbb'<br>
 * <br>
 * ?Map?<br>
 * ??Map? <br>
 * @throws Exception ?????
 */
@Test
public void testGetIndexedPropertyValuesMap17() throws Exception {
    // ??
    JXPathIndexedBeanWrapperImpl bw = new JXPathIndexedBeanWrapperImpl(new HashMap<String, Object>());

    // 
    try {
        bw.getIndexedPropertyValues("aa)aa.bbb");
        fail();
    } catch (IllegalArgumentException e) {
        // OK
        String expect = "Invalid property name. PropertyName: 'aa)aa.bbb'XPath: '/aa)aa/bbb'";
        assertEquals(expect, e.getMessage());
        assertSame(JXPathInvalidSyntaxException.class, e.getCause().getClass());
    }
}

From source file:jp.terasoluna.fw.util.ConvertUtilTest.java

/**
 * testConvertObjectClassboolean07() <br>
 * <br>// w  w  w  .  j av a 2 s.  c  om
 * () <br>
 * G <br>
 * <br>
 * () obj:"abc"<br>
 * () clazz:BigInteger.class<br>
 * () allowsNull:false<br>
 * <br>
 * () :IllegalArgumentException<br>
 * ??:ConversionException<br>
 * <br>
 * CnvertUtils#convert??????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testConvertObjectClassboolean07() throws Exception {

    // 
    try {
        ConvertUtil.convert("abc", BigInteger.class, false);
        fail("IllegalArgumentException???????");
    } catch (IllegalArgumentException e) {
        // 
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertTrue(e.getCause() instanceof ConversionException);
    }
}

From source file:jp.terasoluna.fw.util.ConvertUtilTest.java

/**
 * testToListOfMap08() <br>/* w ww . j  a v a2  s. com*/
 * <br>
 * () <br>
 * G <br>
 * <br>
 * () obj:JavaBean<br>
 * A="value00"<br>
 * () PropertyUtils#describe??: InvocationTargetException JavaBean?getter?RuntimeException<br>
 * <br>
 * () :IllegalArgumentException<br>
 * ??InvocationTargetException<br>
 * <br>
 * PropertyUtils#descrive?InvocationTargetException????? <br>
 * @throws Exception ?????
 */
@Test
public void testToListOfMap08() throws Exception {
    // ??
    ConvertUtil_Stub02 obj = new ConvertUtil_Stub02();
    obj.setA("value00");

    try {
        // 
        ConvertUtil.toListOfMap(obj);
        fail();
    } catch (IllegalArgumentException e) {
        // 
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertTrue(e.getCause() instanceof InvocationTargetException);
    }

}

From source file:jp.terasoluna.fw.util.ConvertUtilTest.java

/**
 * testToListOfMap09() <br>/*from w  ww  .j  av  a  2s. c  om*/
 * <br>
 * () <br>
 * G <br>
 * <br>
 * () obj:JavaBean<br>
 * A="value00"<br>
 * () PropertyUtils#describe??: IllegalAccessException PropertyUtilsBean??IllegalAccessException<br>
 * <br>
 * () :IllegalArgumentException<br>
 * ??IllegalAccessException<br>
 * <br>
 * PropertyUtils#descrive?IllegalAccessException????? <br>
 * @throws Exception ?????
 */
@Test
public void testToListOfMap09() throws Exception {
    // ??
    List<ConvertUtil_Stub01> obj = new ArrayList<ConvertUtil_Stub01>();
    ConvertUtil_Stub01 bean = new ConvertUtil_Stub01();
    bean.setA("value00");
    obj.add(bean);
    BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
    ReflectionTestUtils.setField(beanUtilsBean, "propertyUtilsBean", new ConvertUtil_PropertyUtilsBeanStub01());

    try {
        // 
        ConvertUtil.toListOfMap(obj);
        fail();
    } catch (IllegalArgumentException e) {
        // 
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertTrue(e.getCause() instanceof IllegalAccessException);
    }

}

From source file:jp.terasoluna.fw.util.ConvertUtilTest.java

/**
 * testToListOfMap10() <br>//  w w  w.  j ava  2 s.c om
 * <br>
 * () <br>
 * G <br>
 * <br>
 * () obj:JavaBean<br>
 * A="value00"<br>
 * () PropertyUtils#describe??: NoSuchMethodException PropertyUtilsBean??NoSuchMethodException<br>
 * <br>
 * () :IllegalArgumentException<br>
 * ??NoSuchMethodException<br>
 * <br>
 * PropertyUtils#descrive?NoSuchMethodException????? <br>
 * @throws Exception ?????
 */
@Test
public void testToListOfMap10() throws Exception {
    // ??
    List<ConvertUtil_Stub01> obj = new ArrayList<ConvertUtil_Stub01>();
    ConvertUtil_Stub01 bean = new ConvertUtil_Stub01();
    bean.setA("value00");
    obj.add(bean);
    BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
    ReflectionTestUtils.setField(beanUtilsBean, "propertyUtilsBean", new ConvertUtil_PropertyUtilsBeanStub02());

    try {
        // 
        ConvertUtil.toListOfMap(obj);
        fail();
    } catch (IllegalArgumentException e) {
        // 
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertTrue(e.getCause() instanceof NoSuchMethodException);
    }

}

From source file:com.projity.field.Field.java

public boolean setInternalValue(Object object, Object value, FieldContext context) throws FieldParseException {
    if (context == null)
        context = specialFieldContext;/*from ww  w. j  a v a2s  .  c  o m*/
    if (!FieldContext.isForceValue(context) && isReadOnly(object, context)) { // don't allow setting of read only
        // fields
        // log.warn("Tried to set value of read only field" + getId());
        return false;
    }

    if (value != null && value.equals(getValue(object, context))) // if
        // not
        // change,
        // do
        // nothing
        return false; // TODO certain time-distibued fields need to be
                      // changed

    if (hasExternalType()) { // does the second pass, converting from
        // say, Date to long
        value = FieldConverter.convert(value, internalType, context); // convert
        // from
        // date
        // to
        // long
        // for
        // example
        if (value == null && !isMap()) // TODO is this how to treat null values?
            return false;

    }

    if (range != null) {
        range.validate(value, this);
    }

    if (methodSet == null)
        return false;
    if (FieldContext.isParseOnly(context)) // if just parsing, do not set
        return false;
    try {
        if (isMap()) {
            Map map = (Map) getPropertyValue(object, context);
            map.put(getId(), value);
        } else if (setHasNoContext) {
            methodSet.invoke(object,
                    (isIndexed() ? new Object[] { new Integer(index), value } : new Object[] { value }));
        } else {
            methodSet.invoke(object, (isIndexed() ? new Object[] { new Integer(index), value, context }
                    : new Object[] { value, context }));
        }
        //LC
        if (object instanceof DataObject) {
            if (context == null || !context.isNoDirty())
                ((DataObject) object).setDirty(true);
        }

    } catch (IllegalArgumentException e) {
        throw new FieldParseException(e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        e.printStackTrace();
        if (cause != null && cause instanceof FieldParseException)
            throw (FieldParseException) cause;
        else {
            // setters can throw other values, so don't treat as bad exception
            throw new FieldParseException(cause.getMessage());
        }
    }
    return true;
}

From source file:jp.terasoluna.fw.util.ConvertUtilTest.java

/**
 * testConvertIfNotNull02() <br>/*from  w w w  . jav  a  2  s.  co  m*/
 * <br>
 * () <br>
 * C <br>
 * <br>
 * () obj:null<br>
 * () clazz:Object.class<br>
 * <br>
 * () :IllegalArgumentException<br>
 * ?: "Unable to cast 'null' to '" + clazz??? + "'"<br>
 * ??:ClassCastException<br>
 * ???: "Unable to cast 'null' to '" + clazz??? + "'"<br>
 * <br>
 * obj?null?????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testConvertIfNotNull02() throws Exception {
    // 
    try {
        ConvertUtil.convertIfNotNull(null, Object.class);
        fail("IllegalArgumentException???????");
    } catch (IllegalArgumentException e) {
        // 
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
        assertEquals("Unable to cast 'null' to '" + Object.class.getName() + "'", e.getMessage());
        assertEquals(ClassCastException.class.getName(), e.getCause().getClass().getName());
        assertEquals("Unable to cast 'null' to '" + Object.class.getName() + "'", e.getCause().getMessage());
    }
}