Java 类org.aspectj.lang.annotation.AfterThrowing 实例源码

项目:RoboInsta    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles("dev")) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'",
            joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(),
            e.getCause() != null ? e.getCause() : "NULL", e.getMessage(),
            e
        );

    } else {
        log.error("Exception in {}.{}() with cause = {}",
            joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(),
            e.getCause() != null ? e.getCause() : "NULL"
        );
    }
}
项目:devops-cstack    文件:ModuleAspect.java   
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.service.ModuleService.remove(..)) " +
    "|| execution(* cn.org.once.cstack.service.ModuleService.initModule(..))",
    throwing = "e")
public void afterThrowingModule(StaticPart staticPart,
                                Exception e)
    throws ServiceException {
    User user = this.getAuthentificatedUser();
    Message message = null;
    logger.debug("CALLED CLASS : " + staticPart.getSignature().getName());
    switch (staticPart.getSignature().getName().toUpperCase()) {
        case initModule:
            message = MessageUtils.writeAfterThrowingModuleMessage(e, user,
                initModule);
            break;
        case deleteType:
            message = MessageUtils.writeAfterThrowingModuleMessage(e, user,
                deleteType);
            break;
    }
    if (message != null) {
        messageService.create(message);
    }
}
项目:smartlog    文件:LogAspect.java   
@AfterThrowing(value = "execution(@org.smartlog.aop.Loggable * *(..))", throwing = "t")
public void afterThrowingLoggable(final JoinPoint joinPoint, final Throwable t) throws Throwable {
    final LogContext ctx = SmartLog.throwable(t);

    if (ctx.level() == null) {
        // use ERROR level by default when got uncaught exception
        ctx.level(LogLevel.ERROR);
    }

    final Object result = ctx.result();
    if (result == null) {
        ctx.result(t.toString());
    } else {
        ctx.result(result.toString() + "; " + t.toString());
    }

    finish(joinPoint, ctx);
}
项目:springbootWeb    文件:WebLogAspect.java   
@AfterThrowing(throwing = "ex", pointcut = "webLog()")
public void doAfterThrowing(Throwable ex) {
    //有异常
    WebOosLog commLogger = commLoggerThreadLocal.get();
    if (ex instanceof BusinessException) {
        commLogger.setActionResCode(ResponseStatus.BUSINESS_FAILED);
    } else if (ex instanceof ValidateException) {
        commLogger.setActionResCode(ResponseStatus.VALIDATE_ERR);
    } else if (ex instanceof LoginTimeoutException) {
        commLogger.setActionResCode(ResponseStatus.LOGIN_TIME_OUT);
    } else if (ex instanceof NoPrivilegeException) {
        commLogger.setActionResCode(ResponseStatus.NO_PRIVILEGE);
    } else {
        commLogger.setActionResCode(ResponseStatus.SYSTEM_ERR);
    }
    commLogger.setReqEndTime(new Date());
    commLogger.setReqDealTime((int) (commLogger.getReqEndTime().getTime() - commLogger.getReqStartTime().getTime()));
    commLogger.setIsUndefinedException(true);
    commLogger.setExcepStackInfo(ExceptionUtil.parseException(ex));

    loggerRecordService.doRecord(commLogger);

    logger.debug("EXCEPTION : " + ExceptionUtil.parseException(ex));
    logger.debug("SPEND TIME : " + commLogger.getReqDealTime() + "ms");
    logger.debug("***************请求" + commLogger.getActionDesc() + "结束***************");
}
项目:whatsmars    文件:SystemLogAspect.java   
@AfterThrowing(pointcut = "controllerAspect()", throwing = "exception")
    public void doException(JoinPoint joinPoint, Exception exception) {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        // 读取session中的用户
//      User user = SessionUtils.getUserFromSession(request);

//      if(null == user){
//          logger.info("未登录日志不记录");
//          return;
//      }

        try {
            Object[] args = getLogMethodDescription(joinPoint);

            // *========数据库日志=========*//
//          logService.saveLog(user.getId(), user.getAccount(), LogType.EXCEPTION_LOG,
//                  IpUtils.getIpAddr(request), args[0].toString() + "-->" + exception.getMessage(),
//                  user.getManufacturerId(), reqDescription(request));

        } catch (Exception e) {
            // 记录本地异常日志
            logger.error(e);
            e.printStackTrace();
        }  
    }
项目:SSMSeedProject    文件:LogAspect.java   
@AfterThrowing(throwing = "ex", pointcut = "execution(* com.github.izhangzhihao.SSMSeedProject.*.*.*(..)))")
public void LogToDB(JoinPoint joinPoint, Throwable ex) {
    //出错行
    int lineNumber = ex.getStackTrace()[0].getLineNumber();
    //方法签名
    Signature signature = joinPoint.getSignature();
    //参数
    Object[] args = joinPoint.getArgs();
    //拼接参数
    StringBuilder argString = new StringBuilder();
    if (args.length > 0)
        for (Object arg : args)
            argString.append(arg);
    ex.printStackTrace();
    log.error("方法" + signature, "参数" + argString, "错误行:" + lineNumber, "时间" + new Date(), "异常内容" + ex.toString());
}
项目:automation-test-engine    文件:SystemLogger.java   
/**
     * After throwing advice.
     *
     * @param joinPoint the join point
     * @param error the error
     */
    @AfterThrowing(pointcut = "selectAll()", throwing = "error")
    public void afterThrowingAdvice(JoinPoint joinPoint, Throwable error) {
        if (isAlreadySysPointCut(error)) {
            return;
        }
        setAlreadySysPointCut(error);
        if (error instanceof TestDataException) {
            ITestResult itr = Reporter.getCurrentTestResult();
            itr.setThrowable(error);
        }
//      String[] fullST = Utils.stackTrace(error, false);
//      LogbackWriter.writeSysError(joinPoint.getTarget().toString()+ error.hashCode()  + fullST[1] );
        Class<?> cls = joinPoint.getTarget().getClass();
        if (null == cls) throw GlobalUtils.createInternalError("jvm");
        LogbackWriter.writeSysError(cls,  error);

    }
项目:zswxsqxt    文件:AfterThrowingUtil.java   
/**
 * 出现异常自动记录日志
 * @param ex 异常
 */
@AfterThrowing(pointcut="methods()",
        throwing="ex")
public void ExceptionLog(Exception ex) {
    LoginInfo loginUser = UserContextHolder.getUser();
    //保证用户已经登陆后并通过菜单访问功能时才记录操作时间
    if (loginUser != null ) {
        Log log = new Log();
        log.setDf("0");
        log.setIp(loginUser.getIp());
        log.setPermission(loginUser.getPermission());
        log.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        log.setType("APP_LOG001");
        log.setUsername(loginUser.getUserName());
        logManager.save(log);
    }
}
项目:cxf-server    文件:AuditAspect.java   
@AfterThrowing(
        pointcut = "execution(* (@javax.jws.WebService *).*(..))",
        throwing = "throwable")
public void auditAfterThrowing(JoinPoint joinPoint, Throwable throwable) throws Throwable {
  String id = getId();
  Class targetClass = joinPoint.getTarget().getClass();
  String methodName = joinPoint.getSignature().getName();
  Object[] args = joinPoint.getArgs();

  LOG.info("[" + id + "] After exception: " + targetClass.getName() + "." + methodName + " with " + args.length + " params");

  AuditEntity ae = AuditEntity.getInstance(
          new Timestamp(new Date().getTime()).toString(),
          methodName,
          objectsToString(args),
          throwable != null ? throwable.toString() : null,
          STATE_EXCEPTION
  );

  LOG.info("[" + id + "] Exception: " + ae);
}
项目:jhipster-microservices-example    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:jhipster-microservices-example    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:jhipster-microservices-example    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:MTC_Labrat    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:LazyREST    文件:ExceptionLogAspect.java   
/**
 * @param joinPoint
 * @param e
 */
@AfterThrowing(value = "doAfterThrowing()", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Throwable e) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("className", joinPoint.getTarget().getClass().getName());
    map.put("methodName", method.getName());
    map.put("args", JSONUtils.toJSONString(joinPoint.getArgs().toString()));
    map.put("errorMsg", e.getMessage());
    logger.error(JSONUtils.toJSONString(map));
}
项目:buenojo    文件:LoggingAspect.java   
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause(), e);
    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause());
    }
}
项目:devops-cstack    文件:ServerAspect.java   
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.ServerService.updateType(..))", throwing = "e")
public void afterThrowingServer(StaticPart staticPart, Exception e) throws ServiceException {
    User user = this.getAuthentificatedUser();
    Message message = null;
    logger.debug("CALLED CLASS : " + staticPart.getSignature().getName());
    switch (staticPart.getSignature().getName().toUpperCase()) {
    case updateType:
        message = MessageUtils.writeAfterThrowingModuleMessage(e, user, updateType);
        break;
    }
    if (message != null) {
        messageService.create(message);
    }
}
项目:devops-cstack    文件:ErrorHandlerAspect.java   
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.service.*.*(..))",
        throwing= "error")
public void logAfterThrowing(Throwable error) {
    if(error.getMessage() != null && error.getMessage()
            .contains("org.hibernate.exception.JDBCConnectionException: could not extract ResultSet")) {
        publisher.publishEvent(new DatabaseConnectionFailEvent("Database connection has been lost"));
    }
}
项目:allure-java    文件:Allure1StepsAspects.java   
@AfterThrowing(pointcut = "anyMethod() && withStepAnnotation()", throwing = "e")
public void stepFailed(final JoinPoint joinPoint, final Throwable e) {
    getLifecycle().updateStep(result -> result
            .withStatus(getStatus(e).orElse(Status.BROKEN))
            .withStatusDetails(getStatusDetails(e).orElse(null)));
    getLifecycle().stopStep();
}
项目:Armory    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:Armory    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:alfresco-repository    文件:RouteTestExtesnions.java   
@AfterThrowing(pointcut = "execution(@org.alfresco.traitextender.Extend * *(..) throws TestException) && (@annotation(extendAnnotation))", throwing = "ete")
public void intercept(Extend extendAnnotation, ExtensionTargetException ete) throws TestException
{
    Throwable exception = AJExtender.asCheckThrowable(ete.getCause(),
                                                      TestException.class);
    if (exception instanceof TestException)
    {
        throw (TestException) exception;
    }
    else
    {
        throw ete;
    }
}
项目:patient-portal    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:sentry    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:SpringBootDemoApp    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature()
        .getDeclaringTypeName(),
        joinPoint.getSignature()
            .getName(),
        e.getCause() != null ? e.getCause() : "NULL", e.getMessage(), e);
}
项目:TorgCRM-Server    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:speakTogether    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:Code4Health-Platform    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:controller-logger    文件:GenericControllerAspect.java   
@AfterThrowing(
        pointcut = "allPublicControllerMethodsPointcut() && "
                + "methodLoggingNotDisabledPointcut() && "
                + "methodOrClassLoggingEnabledPointcut()",
        throwing = "t")
public void onException(@Nonnull JoinPoint joinPoint, @Nonnull Throwable t) {
    String methodName = joinPoint.getSignature().getName() + "()";
    LOG.info(methodName + " threw exception: [" + t + "]");
}
项目:spring-io    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:spring-io    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:spring-io    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:spring-io    文件:LoggingAspect.java   
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
项目:lams    文件:AbstractAspectJAdvisorFactory.java   
/**
 * Find and return the first AspectJ annotation on the given method
 * (there <i>should</i> only be one anyway...)
 */
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
    Class<?>[] classesToLookFor = new Class<?>[] {
            Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
    for (Class<?> c : classesToLookFor) {
        AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
        if (foundAnnotation != null) {
            return foundAnnotation;
        }
    }
    return null;
}
项目:training-sample    文件:LogAspect.java   
@AfterThrowing(pointcut = "pointcut()", throwing = "error")
public void logAfterThrowing(JoinPoint joinPoint, Throwable error) {
    System.out.println("******");
    System.out.println("logAfterThrowing() is running!");
    System.out.println("hijacked : " + joinPoint.getSignature().getName());
    System.out.println("Exception : " + error);
    System.out.println("******");

}
项目:eventapis    文件:CommandExecutionInterceptor.java   
@AfterThrowing(value = "within(com.kloia.eventapis.api.CommandHandler+ || com.kloia.eventapis.api.EventHandler+) && execution(* execute(..))", throwing = "e")
public void afterThrowing( Exception e) throws Throwable {
    try {
        log.info("afterThrowing method:"+e);
        kafkaOperationRepository.failOperation(operationContext.getContext(),operationContext.getCommandContext(),event -> event.setEventState(EventState.TXN_FAILED));
    } finally {
        operationContext.clearContext();
    }
}
项目:stuffEngine    文件:AuditHandler.java   
@AfterThrowing(pointcut = "empController() && anyMethod() && args(empId, request)", throwing = "e")
public void handleAfterMethodWithEmpIdThrow(JoinPoint joinPoint, Integer empId, HttpServletRequest request, Throwable e) {
    int action = Integer.parseInt((((MethodSignature)joinPoint.getSignature())
            .getMethod()).getAnnotation(RequestMapping.class).name());
    AuditInfo auditRecord = new AuditInfo(null, empId, request.getRemoteAddr(), "Id: "+empId, action, e.getMessage());
    auditService.createRecord(auditRecord);
}
项目:stuffEngine    文件:AuditHandler.java   
@AfterThrowing(pointcut = "empController() && anyMethod() && args(emp, request)", throwing= "e")
public void handleAfterMethodWithEmpThrows(JoinPoint joinPoint, Employee emp, HttpServletRequest request, Throwable e) {
    int action = Integer.parseInt((((MethodSignature)joinPoint.getSignature())
            .getMethod()).getAnnotation(RequestMapping.class).name());
    AuditInfo auditRecord = new AuditInfo(null, emp.getEmpID()==0?null:emp.getEmpID(), request.getRemoteAddr(), emp.toString(), action, e.getMessage());
    auditService.createRecord(auditRecord);
}
项目:stuffEngine    文件:AuditHandler.java   
@AfterThrowing(pointcut = "empController() && anyMethod() &&  args(request)", throwing = "e")
public void handleAfterMethodAllEmpThrow(JoinPoint joinPoint, Throwable e, HttpServletRequest request) {
    int action = Integer.parseInt((((MethodSignature)joinPoint.getSignature())
            .getMethod()).getAnnotation(RequestMapping.class).name());

        AuditInfo auditRecord = new AuditInfo(null,null, request.getRemoteAddr(), "Get all emp", action, e.getMessage());
        auditService.createRecord(auditRecord);
}
项目:stuffEngine    文件:AuditHandler.java   
@AfterThrowing(pointcut = "empController() && anyMethod() && args(start, num, request) )", throwing = "e")
public void handleAfterMethodPartEmpThrow(JoinPoint joinPoint, Throwable e, int start, int num, HttpServletRequest request) {
    int action = Integer.parseInt((((MethodSignature)joinPoint.getSignature())
            .getMethod()).getAnnotation(RequestMapping.class).name());

    AuditInfo auditRecord = new AuditInfo(null,null, request.getRemoteAddr(), "Start:num - " +start +":"+num, action, e.getMessage());
    auditService.createRecord(auditRecord);
}
项目:stuffEngine    文件:AuditHandler.java   
@AfterThrowing(pointcut = "empController() && anyMethod() && args(.., request) )", throwing = "e")
public void handleAfterMethodIntCertThrow(JoinPoint joinPoint, Throwable e, HttpServletRequest request) {
    int action = Integer.parseInt((((MethodSignature)joinPoint.getSignature())
            .getMethod()).getAnnotation(RequestMapping.class).name());
    AuditInfo auditRecord = new AuditInfo(null, null, request.getRemoteAddr(), "", action, e.getMessage());
    auditService.createRecord(auditRecord);
}