Code example for InvocationTargetException

Methods: getCause

0
 
    try { 
      Method parseFrom = c.getMethod("parseFrom", InputStream.class);
      return parseFrom.invoke(null, body.in());
    } catch (InvocationTargetException e) {
      throw new ConversionException(c.getName() + ".parseFrom() failed", e.getCause());
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException("Expected a protobuf message but was " + c.getName());
    } catch (IllegalAccessException e) {
      throw new AssertionError();
    } catch (IOException e) {
      throw new ConversionException(e);
    } 
  } 
 
  @Override public TypedOutput toBody(Object object) { 
    if (!(object instanceof AbstractMessageLite)) { 
      throw new IllegalArgumentException(
          "Expected a protobuf message but was " + (object != null ? object.getClass().getName() 
              : "null"));