org.aspectj.lang.annotation.AfterThrowing Java Examples

The following examples show how to use org.aspectj.lang.annotation.AfterThrowing. 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 File: AspectLog.java    From mySpringBoot with 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 File: LoggingAspect.java    From jhipster-online with 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 File: LoggingAspect.java    From Full-Stack-Development-with-JHipster with 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");
    }
}
 
Example #4
Source File: GenericControllerAspect.java    From controller-logger with Apache License 2.0 5 votes vote down vote up
@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 + "]");
}
 
Example #5
Source File: LogAspectj.java    From shop with GNU General Public License v3.0 5 votes vote down vote up
@AfterThrowing(value = "execution(* cn.cie.controller.*Controller.*(..)) && !execution( * cn.cie.controller.AbstractController.*(..))", throwing = "e")
// 切面为controller中的所有方法
public void errorAccess(Throwable e) {
    PropertyConfigurator.configure(this.getClass().getClassLoader().getResource("/").getPath() + "log4j-error.properties");
    if (e instanceof Exception) {
        logger.error("", e);
    }
}
 
Example #6
Source File: LoggingAspect.java    From jhipster-microservices-example with 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 #7
Source File: LoggingAspect.java    From cubeai with 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 #8
Source File: LoggingAspect.java    From flair-engine with 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 File: ServiceMonitor.java    From springboot-seed with 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 File: LoggerAspect.java    From mogu_blog_v2 with 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 #11
Source File: LoggingAspect.java    From cubeai with 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 #12
Source File: LoggingAspect.java    From cubeai with 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 #13
Source File: AbstractAspectJAdvisorFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #14
Source File: LoggingAspect.java    From cubeai with 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 #15
Source File: LoggingAspect.java    From cubeai with 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 File: GenericControllerAspect.java    From summerframework with 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 #17
Source File: LoggingAspect.java    From patient-batch-loader with GNU General Public License v3.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(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");
	}
}
 
Example #18
Source File: LoggingAspect.java    From cubeai with 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 File: LoggingAspect.java    From klask-io with 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 #20
Source File: LoggingAspect.java    From e-commerce-microservice with 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 #21
Source File: AllureAspectJ.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@AfterThrowing(pointcut = "anyAssert()", throwing = "e")
public void stepFailed(final Throwable e) {
    getLifecycle().updateStep(s -> s
            .setStatus(getStatus(e).orElse(Status.BROKEN))
            .setStatusDetails(getStatusDetails(e).orElse(null)));
    getLifecycle().stopStep();
}
 
Example #22
Source File: LoggingAspect.java    From e-commerce-microservice with 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 File: LogAspect.java    From sk-admin with 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 #24
Source File: LogAspect.java    From eladmin with 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 = RequestHolder.getHttpServletRequest();
    logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log);
}
 
Example #25
Source File: LoggingAspect.java    From Spring-5.0-Projects with 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");
    }
}
 
Example #26
Source File: LoggingAspect.java    From okta-jhipster-microservices-oauth-example with 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 #27
Source File: LoggingAspect.java    From okta-jhipster-microservices-oauth-example with 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 #28
Source File: LoggingAspect.java    From okta-jhipster-microservices-oauth-example with 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 #29
Source File: KlockAspectHandler.java    From spring-boot-klock-starter with Apache License 2.0 5 votes vote down vote up
@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 #30
Source File: LoggingAspect.java    From TeamDojo with 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");
    }
}