java.lang.reflect.InvocationTargetException#getMessage ( )源码实例Demo

下面列出了java.lang.reflect.InvocationTargetException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: clickhouse-jdbc   文件: LogProxy.java
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String msg =
        "Call class: " + object.getClass().getName() +
        "\nMethod: " + method.getName() +
        "\nObject: " + object +
        "\nArgs: " + Arrays.toString(args) +
        "\nInvoke result: ";
    try {
        final Object invokeResult = method.invoke(object, args);
        msg +=  invokeResult;
        return invokeResult;
    } catch (InvocationTargetException e) {
        msg += e.getMessage();
        throw e.getTargetException();
    } finally {
        msg = "==== ClickHouse JDBC trace begin ====\n" + msg + "\n==== ClickHouse JDBC trace end ====";
        log.trace(msg);
    }
}
 
源代码2 项目: APICloud-Studio   文件: ExceptionHandler.java
protected void perform(InvocationTargetException e, Shell shell, String title, String message)
{
	Throwable target = e.getTargetException();
	if (target instanceof CoreException)
	{
		perform((CoreException) target, shell, title, message);
	}
	else
	{
		IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG);
		if (e.getMessage() != null && e.getMessage().length() > 0)
		{
			displayMessageDialog(e, e.getMessage(), shell, title, message);
		}
		else
		{
			displayMessageDialog(e, target.getMessage(), shell, title, message);
		}
	}
}
 
源代码3 项目: Plan   文件: MethodWrapper.java
public T callMethod(DataExtension extension, Parameters with) {
    if (disabled) return null;
    try {
        return returnType.cast(with.usingOn(extension, method));
    } catch (InvocationTargetException notReadyToBeCalled) {
        if (notReadyToBeCalled.getCause() instanceof NotReadyException) {
            return null; // Data or API not available to make the call.
        } else {
            throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " could not be called: " + notReadyToBeCalled.getMessage(), notReadyToBeCalled);
        }
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " could not be called: " + e.getMessage(), e);
    }
}
 
源代码4 项目: SaveAndroidResources   文件: Bus.java
/**
 * Throw a {@link RuntimeException} with given message and cause lifted from an {@link
 * InvocationTargetException}. If the specified {@link InvocationTargetException} does not have a
 * cause, neither will the {@link RuntimeException}.
 */
private static void throwRuntimeException(String msg, InvocationTargetException e) {
    Throwable cause = e.getCause();
    if (cause != null) {
        throw new RuntimeException(msg + ": " + cause.getMessage(), cause);
    } else {
        throw new RuntimeException(msg + ": " + e.getMessage(), e);
    }
}
 
源代码5 项目: android-project-wo2b   文件: Bus.java
/**
 * Throw a {@link RuntimeException} with given message and cause lifted from an {@link
 * InvocationTargetException}. If the specified {@link InvocationTargetException} does not have a
 * cause, neither will the {@link RuntimeException}.
 */
private static void throwRuntimeException(String msg, InvocationTargetException e) {
  Throwable cause = e.getCause();
  if (cause != null) {
    throw new RuntimeException(msg + ": " + cause.getMessage(), cause);
  } else {
    throw new RuntimeException(msg + ": " + e.getMessage(), e);
  }
}
 
源代码6 项目: jolie   文件: JavaService.java
private static Object[] getArguments( final JavaOperation javaOperation, final CommMessage message )
	throws IllegalAccessException {
	if( javaOperation.parameterConstructor == null ) {
		return new Object[ 0 ];
	} else {
		try {
			return new Object[] { javaOperation.parameterConstructor.invoke( null, message.value() ) };
		} catch( InvocationTargetException e ) {
			throw new IllegalAccessException( e.getMessage() );
		}
	}
}
 
源代码7 项目: CPUSim   文件: Lax.java
/**
 * Call all end tag methods in the handler list
 * @param qName the ending tag
 * @throws org.xml.sax.SAXException if something goes wrong when parsing
 */
public void endElement(String uri, String localName, String qName)
        throws SAXException
{
    int i;
    String sEndMethodName = "end" + qName;

    // Call every tag start method for this tag found in the list
    //of handlers.
    for (i = 0; i < _vecHandlers.size(); i++) {
        Object oThisHandler = _vecHandlers.elementAt(i);
        Method mEndMethod =
                mFindMethod(oThisHandler, sEndMethodName, _caNoArgs);
        if (mEndMethod != null) {
            try {
                mEndMethod.invoke(oThisHandler);
            } catch (InvocationTargetException ite) {
                //Note:  java.lang.reflect.InvocationTargetException.getMessage()
                //just returns the ite's message even if it is null.  So
                //in that case, we'll rewrap the target exception
                //in a SAXException.
                if (ite.getMessage() == null
                        && ite.getTargetException() != null
                        && ite.getTargetException() instanceof Exception)
                    throw new SAXException((Exception) ite.getTargetException());
                else
                    throw new SAXException(ite);
            } catch (Exception mre) {
                throw new SAXException(mre);
            }
        }
    }
    popTag();
}
 
源代码8 项目: Noyze   文件: Bus.java
/**
 * Throw a {@link RuntimeException} with given message and cause lifted from an {@link
 * InvocationTargetException}. If the specified {@link InvocationTargetException} does not have a
 * cause, neither will the {@link RuntimeException}.
 */
protected static void throwRuntimeException(String msg, InvocationTargetException e) {
  Throwable cause = e.getCause();
  if (cause != null) {
    throw new RuntimeException(msg + ": " + cause.getMessage(), cause);
  } else {
    throw new RuntimeException(msg + ": " + e.getMessage(), e);
  }
}
 
protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
	Throwable target= e.getTargetException();
	if (target instanceof CoreException) {
		perform((CoreException)target, shell, title, message);
	} else {
		JavaPlugin.log(e);
		if (e.getMessage() != null && e.getMessage().length() > 0) {
			displayMessageDialog(e.getMessage(), shell, title, message);
		} else {
			displayMessageDialog(target.getMessage(), shell, title, message);
		}
	}
}
 
源代码10 项目: Noyze   文件: Bus.java
/**
 * Throw a {@link RuntimeException} with given message and cause lifted from an {@link
 * InvocationTargetException}. If the specified {@link InvocationTargetException} does not have a
 * cause, neither will the {@link RuntimeException}.
 */
protected static void throwRuntimeException(String msg, InvocationTargetException e) {
  Throwable cause = e.getCause();
  if (cause != null) {
    throw new RuntimeException(msg + ": " + cause.getMessage(), cause);
  } else {
    throw new RuntimeException(msg + ": " + e.getMessage(), e);
  }
}
 
源代码11 项目: CPUSim   文件: Lax.java
/**
 * Handle an incoming block of text by calling the textOf method for the
 * current tag.
 */
public void characters(char[] caChars, int iStart, int iEnd)
        throws SAXException
{
    String sCurrentTag = sCurrentTag();

    if (sCurrentTag != null) {
        int i;
        String sTextMethodName = "textOf" + sCurrentTag;
        String sArg = null;

        // Call every text method for current tag found in the list
        //of handlers
        for (i = 0; i < _vecHandlers.size(); i++) {
            Object oThisHandler = _vecHandlers.elementAt(i);
            Method mTextMethod =
                    mFindMethod(oThisHandler, sTextMethodName, _caString);
            if (mTextMethod != null) {
                if (sArg == null) {
                    sArg = new String(caChars, iStart, iEnd);
                }
                try {
                    mTextMethod.invoke(oThisHandler, sArg);
                } catch (InvocationTargetException ite) {
                    //Note:  java.lang.reflect.InvocationTargetException.getMessage()
                    //just returns the ite's message even if it is null.  So
                    //in that case, we'll rewrap the target exception
                    //in a SAXException.
                    if (ite.getMessage() == null
                            && ite.getTargetException() != null
                            && ite.getTargetException() instanceof Exception)
                        throw new SAXException((Exception) ite.getTargetException());
                    else
                        throw new SAXException(ite);
                } catch (Exception mre) {
                    throw new SAXException(mre);
                }
            }
        }
    }
}
 
源代码12 项目: CPUSim   文件: Lax.java
/**
 * Call all start methods for this tag.
 * @param qName the start tag
 * @param alAttrs the attributes
 * @throws org.xml.sax.SAXException if something goes wrong
 */
public void startElement(String uri, String localName,
                         String qName, Attributes alAttrs)
        throws org.xml.sax.SAXException
{
    int i;
    String sStartMethodName = "start" + qName;

    pushTag(qName);

    // Call every tag start method for this tag found in the list of handlers.
    for (i = 0; i < _vecHandlers.size(); i++) {
        Object oThisHandler = _vecHandlers.elementAt(i);
        Method mStartMethod = mFindMethod(oThisHandler, sStartMethodName, _caAttrList);
        if (mStartMethod == null) {
            mStartMethod = mFindMethod(oThisHandler, sStartMethodName, _caNoArgs);
        }
        if (mStartMethod != null) {
            // Call start method with or without attribute list
            Class[] caMethodArgs = mStartMethod.getParameterTypes();
            try {
                if (caMethodArgs.length == 0) {
                    mStartMethod.invoke(oThisHandler);
                }
                else {
                    mStartMethod.invoke(oThisHandler, alAttrs);
                }
            } catch (InvocationTargetException ite) {
                //Note:  java.lang.reflect.InvocationTargetException.getMessage()
                //just returns the ite's message even if it is null.  So
                //in that case, we'll rewrap the target exception
                //in a SAXException.
                //ite.printStackTrace();
                if (ite.getMessage() == null
                        && ite.getTargetException() != null
                        && ite.getTargetException() instanceof Exception)
                    throw new SAXException((Exception) ite.getTargetException());
                else
                    throw new SAXException(ite);
            } catch (Exception mre) {
                throw new SAXException(mre);
            }
        }
    }
}
 
源代码13 项目: Tatala-RPC   文件: ServerSession.java
private Object execute(TransferObject to) throws SocketExecuteException{
	Object retobj = null;
	
	try {
		String calleeClassName = to.getCalleeClass();
		String calleeMethod = to.getCalleeMethod();
		
		if(calleeClassName == null){
			throw new SocketExecuteException("No connection with client.");
		}
		
		//Check default proxy, don't need reflection.
		if(to.isDefaultCallee() || calleeClassName.equals(TransferObject.DEFAULT_PROXY)){
			if(defaultProxy != null){
				retobj = defaultProxy.execute(to);
			}
		} else {
			Class<?> calleeClass = null;
			Object calleeObject = null;
			
			if(calleeClassCache.containsKey(calleeClassName)){
				calleeClass = calleeClassCache.get(calleeClassName);
				calleeObject = calleeObjectCache.get(calleeClassName);
			} else {
				calleeClass = Class.forName(calleeClassName);
				calleeObject = calleeClass.newInstance();
				
				calleeClassCache.put(calleeClassName, calleeClass);
				calleeObjectCache.put(calleeClassName, calleeObject);
			}
			
			if(calleeClass == null || calleeObject == null){
				throw new SocketExecuteException("No connection with client.");
			}
			
			Method meth = calleeClass.getMethod(calleeMethod, TransferObject.class);
			retobj = meth.invoke(calleeObject, to);
		}
	} catch (InvocationTargetException ite) {
		if(ite.getCause() instanceof TatalaRollbackException){
			TatalaRollbackException tre = (TatalaRollbackException)ite.getCause();
			throw tre;
		} else {
			log.error("Server execute error e: " + ite, ite);
			throw new SocketExecuteException("Server execute error e: " + ite.getMessage());
		}

	} catch (Exception e) {
		log.error("Server execute error e: " + e, e);
		throw new SocketExecuteException("Server execute error e: " + e.getMessage());
	} 
	
	return retobj;
}
 
源代码14 项目: Tatala-RPC   文件: ServerSession.java
private Object execute(TransferObject to) throws SocketExecuteException{
	Object retobj = null;
	
	try {
		String calleeClassName = to.getCalleeClass();
		String calleeMethod = to.getCalleeMethod();
		
		if(calleeClassName == null){
			throw new SocketExecuteException("No connection with client.");
		}
		
		//Check default proxy, don't need reflection.
		if(to.isDefaultCallee() || calleeClassName.equals(TransferObject.DEFAULT_PROXY)){
			if(defaultProxy != null){
				retobj = defaultProxy.execute(to);
			}
		} else {
			Class<?> calleeClass = null;
			Object calleeObject = null;
			
			if(calleeClassCache.containsKey(calleeClassName)){
				calleeClass = calleeClassCache.get(calleeClassName);
				calleeObject = calleeObjectCache.get(calleeClassName);
			} else {
				calleeClass = Class.forName(calleeClassName);
				calleeObject = calleeClass.newInstance();
				
				calleeClassCache.put(calleeClassName, calleeClass);
				calleeObjectCache.put(calleeClassName, calleeObject);
			}
			
			if(calleeClass == null || calleeObject == null){
				throw new SocketExecuteException("No connection with client.");
			}
			
			Method meth = calleeClass.getMethod(calleeMethod, TransferObject.class);
			retobj = meth.invoke(calleeObject, to);
		}
	} catch (InvocationTargetException ite) {
		if(ite.getCause() instanceof TatalaRollbackException){
			TatalaRollbackException tre = (TatalaRollbackException)ite.getCause();
			throw tre;
		} else {
			log.error("Server execute error e: " + ite, ite);
			throw new SocketExecuteException("Server execute error e: " + ite.getMessage());
		}

	} catch (Exception e) {
		log.error("Server execute error e: " + e, e);
		throw new SocketExecuteException("Server execute error e: " + e.getMessage());
	} 
	
	return retobj;
}
 
源代码15 项目: Tatala-RPC   文件: ServerSession.java
private Object execute(TransferObject to) throws SocketExecuteException{
	Object retobj = null;
	
	try {
		String calleeClassName = to.getCalleeClass();
		String calleeMethod = to.getCalleeMethod();
		
		if(calleeClassName == null){
			throw new SocketExecuteException("No connection with client.");
		}
		
		//Check default proxy, don't need reflection.
		if(calleeClassName.equals(TransferObject.DEFAULT_PROXY)){
			if(defaultProxy != null){
				retobj = defaultProxy.execute(to);
			}
		} else {
			Class<?> calleeClass = null;
			Object calleeObject = null;
			
			if(calleeClassCache.containsKey(calleeClassName)){
				calleeClass = calleeClassCache.get(calleeClassName);
				calleeObject = calleeObjectCache.get(calleeClassName);
			} else {
				calleeClass = Class.forName(calleeClassName);
				calleeObject = calleeClass.newInstance();
				
				calleeClassCache.put(calleeClassName, calleeClass);
				calleeObjectCache.put(calleeClassName, calleeObject);
			}
			
			if(calleeClass == null || calleeObject == null){
				throw new SocketExecuteException("No connection with client.");
			}
			
			Method meth = calleeClass.getMethod(calleeMethod, TransferObject.class);
			retobj = meth.invoke(calleeObject, to);
		}
	} catch (InvocationTargetException ite) {
		if(ite.getCause() instanceof TatalaReturnException){
			TatalaReturnException tre = (TatalaReturnException)ite.getCause();
			throw tre;
		} else {
			log.error("Server execute error e: " + ite, ite);
			throw new SocketExecuteException("Server execute error e: " + ite.getMessage());
		}

	} catch (Exception e) {
		log.error("Server execute error e: " + e, e);
		throw new SocketExecuteException("Server execute error e: " + e.getMessage());
	} 
	
	return retobj;
}