AndLinker icon indicating copy to clipboard operation
AndLinker copied to clipboard

关于异常日志打印

Open CoderBuck opened this issue 5 years ago • 1 comments

// MethodExecutor.java

Response execute(Object[] args) {
    Object result = null;
    int statusCode = Response.STATUS_CODE_SUCCESS;
    String resultMsg = String.format("Call method '%s' successfully!", mMethod.getName());
    Throwable throwable = null;
    try {
        result = mMethod.invoke(mTarget, args);
    } catch (IllegalAccessException e) {
        statusCode = Response.STATUS_CODE_ILLEGAL_ACCESS;
        throwable = e;
    } catch (InvocationTargetException e) {
        statusCode = Response.STATUS_CODE_INVOCATION_FAIL;
        throwable = e;
    }
    if (throwable != null) {
        resultMsg = "Exception occur when execute method:" + mMethod.getName() + '\n' + throwable.getMessage();

        // 增加
        throwable.printStackTrace();
    }
    return new Response(statusCode, resultMsg, result);
}

// 增加 throwable.printStackTrace(); 建议这里加上异常堆栈打印,方便定位异常问题

CoderBuck avatar Aug 12 '19 09:08 CoderBuck

应该直接给他发pull request

imcloud avatar Dec 05 '19 04:12 imcloud