Java Code Examples for org.aspectj.lang.annotation.AfterThrowing

The following examples show how to use org.aspectj.lang.annotation.AfterThrowing. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mySpringBoot   Source File: AspectLog.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 调用后的异常处理
 * @param p
 * @param e
 */
@AfterThrowing(pointcut = "methodCachePointcut()", throwing = "e")
public void doAfterThrowing(JoinPoint p, Throwable e) throws Throwable {
    //业务异常不用记录
    if(!(e instanceof ServiceException)) {
        try {
            SystemLog systemLog =getSystemLogInit(p);
            systemLog.setLogType(SystemLog.LOGERROR);
            systemLog.setExceptionCode(e.getClass().getName());
            systemLog.setExceptionDetail(e.getMessage());
            systemLogQueue.add(systemLog);
        } catch (Exception ex) {
            logger.error("==异常通知异常==");
            logger.error("异常信息:{}", ex.getMessage());
        }
    }
}
 
Example 2
Source Project: jhipster-online   Source File: LoggingAspect.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
        logger(joinPoint)
            .error(
                "Exception in {}() with cause = \'{}\' and exception = \'{}\'",
                joinPoint.getSignature().getName(),
                e.getCause() != null ? e.getCause() : "NULL",
                e.getMessage(),
                e
            );
    } else {
        logger(joinPoint)
            .error(
                "Exception in {}() with cause = {}",
                joinPoint.getSignature().getName(),
                e.getCause() != null ? e.getCause() : "NULL"
            );
    }
}
 
Example 3
Source Project: sk-admin   Source File: LogAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 配置异常通知
 *
 * @param joinPoint join point for advice
 * @param e         exception
 */
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    Log log = new Log("ERROR", System.currentTimeMillis() - currentTime.get());
    currentTime.remove();
    log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
    HttpServletRequest request = SecurityUtils.getHttpServletRequest();
    logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
}
 
Example 4
Source Project: eventapis   Source File: EventExecutionInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
@AfterThrowing(value = "this(com.kloia.eventapis.api.EventHandler+) && execution(* execute(..))", throwing = "exception")
public void afterThrowing(Exception exception) throws Throwable {
    try {
        log.debug("afterThrowing EventHandler method:" + exception.getMessage());
        kafkaOperationRepository.failOperation(operationContext.getCommandContext(), event -> event.setEventState(EventState.TXN_FAILED));
    } finally {
        operationContext.clearCommandContext();
        userContext.clearUserContext();
    }
}
 
Example 5
Source Project: eventapis   Source File: CommandExecutionInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
@AfterThrowing(value = "this(com.kloia.eventapis.api.CommandHandler) && @annotation(command)", throwing = "exception")
public void afterThrowing(Command command, Exception exception) {
    try {
        log.info("afterThrowing Command: " + exception);
        kafkaOperationRepository.failOperation(operationContext.getCommandContext(), event -> event.setEventState(EventState.TXN_FAILED));
    } finally {
        operationContext.clearCommandContext();
    }
}
 
Example 6
Source Project: flair-registry   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 7
Source Project: mogu_blog_v2   Source File: LoggerAspect.java    License: Apache License 2.0 5 votes vote down vote up
@AfterThrowing(value = "pointcut(operationLogger)", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, OperationLogger operationLogger, Throwable e) throws Exception {

    ExceptionLog exception = new ExceptionLog();
    HttpServletRequest request = RequestHolder.getRequest();
    String ip = IpUtils.getIpAddr(request);
    exception.setIp(ip);
    String operationName = AspectUtil.INSTANCE.parseParams(joinPoint.getArgs(), operationLogger.value());

    //从Redis中获取IP来源
    String jsonResult = redisUtil.get(SysConf.IP_SOURCE + BaseSysConf.REDIS_SEGMENTATION + ip);
    if (StringUtils.isEmpty(jsonResult)) {
        String addresses = IpUtils.getAddresses(SysConf.IP + SysConf.EQUAL_TO + ip, SysConf.UTF_8);
        if (StringUtils.isNotEmpty(addresses)) {
            exception.setIpSource(addresses);
            redisUtil.setEx(SysConf.IP_SOURCE + BaseSysConf.REDIS_SEGMENTATION + ip, addresses, 24, TimeUnit.HOURS);
        }
    } else {
        exception.setIpSource(jsonResult);
    }

    //设置请求信息
    exception.setIp(ip);

    //设置调用的方法
    exception.setMethod(joinPoint.getSignature().getName());

    exception.setExceptionJson(JSON.toJSONString(e,
            SerializerFeature.DisableCircularReferenceDetect,
            SerializerFeature.WriteMapNullValue));
    exception.setExceptionMessage(e.getMessage());

    exception.setOperation(operationName);
    exception.setCreateTime(new Date());
    exception.setUpdateTime(new Date());

    exception.insert();
}
 
Example 8
Source Project: flair-engine   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 9
Source Project: springboot-seed   Source File: ServiceMonitor.java    License: MIT License 5 votes vote down vote up
/**
 * Monitor whether exception is thrown in service layer. If exception
 * has been thrown, in order to detecting it conveniently, log the
 * situation where it happened. Then create a server internal error
 * exception and throw it out.
 */
@AfterThrowing(pointcut = "com.wind.monitor.ServiceMonitor.serviceLayer()", throwing = "e")
public void monitorException(JoinPoint joinPoint, Throwable e) {
    // Log the situation where exception happened
    Object[] args = joinPoint.getArgs();
    Signature signature = joinPoint.getSignature();
    log.error("[" + signature.toShortString() + "]" + Arrays.toString(args) + "[" + e.toString() + "]");

    // Throw a new server internal error exception
    throw new ServerInternalErrorException(e.getMessage(), e);
}
 
Example 10
Source Project: sophia_scaffolding   Source File: ApiLogAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常通知
 *
 * @param e
 */
@AfterThrowing(pointcut = "log()", throwing = "e")
public void doAfterThrowable(Throwable e) {
    //得到当前线程的log对象
    ApiLogger apiLogger = logThreadLocal.get();
    // 发布事件
    publisher.publishEvent(new SysLogEvent(apiLogger));
    //移除当前log实体
    logThreadLocal.remove();
}
 
Example 11
Source Project: sophia_scaffolding   Source File: ApiLogAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 异常通知
 *
 * @param e
 */
@AfterThrowing(pointcut = "log()", throwing = "e")
public void doAfterThrowable(Throwable e) {
    //得到当前线程的log对象
    ApiLogger apiLogger = logThreadLocal.get();
    // 发布事件
    publisher.publishEvent(new SysLogEvent(apiLogger));
    //移除当前log实体
    logThreadLocal.remove();
}
 
Example 12
Source Project: java-microservices-examples   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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(Profiles.of(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");
    }
}
 
Example 13
Source Project: java-microservices-examples   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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(Profiles.of(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");
    }
}
 
Example 14
Source Project: java-microservices-examples   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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(Profiles.of(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");
    }
}
 
Example 15
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 16
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 17
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 18
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 19
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 20
/**
 * 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;
}
 
Example 21
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 22
Source Project: cubeai   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 23
Source Project: summerframework   Source File: GenericControllerAspect.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@AfterThrowing(pointcut = "allPublicControllerMethodsPointcut() || methodOrClassMonitorEnabledPointcut()",
    throwing = "t")
public void onException(JoinPoint joinPoint, Throwable t) {
    String methodName = joinPoint.getSignature().getName() + "()";
    LOG.info(methodName + " threw exception: [" + t + "]");
}
 
Example 24
Source Project: klask-io   Source File: LoggingAspect.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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(), e);
    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause());
    }
}
 
Example 25
/**
 * 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");
    }
}
 
Example 26
/**
 * 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");
    }
}
 
Example 27
/**
 * 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");
    }
}
 
Example 28
@AfterThrowing(value = "@annotation(klock)", throwing = "ex")
public void afterThrowing (JoinPoint joinPoint, Klock klock, Throwable ex) throws Throwable {
    String curentLock = this.getCurrentLockId(joinPoint,klock);
    releaseLock(klock, joinPoint,curentLock);
    cleanUpThreadLocal(curentLock);
    throw ex;
}
 
Example 29
Source Project: TeamDojo   Source File: LoggingAspect.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example 30
Source Project: Spring-5.0-Projects   Source File: LoggingAspect.java    License: MIT License 5 votes vote down vote up
/**
 * 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");
    }
}