반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Spring Open Feign
- ChannelPipeline
- spring boot redis
- grafana
- netflix oss
- MySQL
- QueryDSL
- Airflow
- mybatis
- jmeter
- KAFKA
- Hibernate
- spring cloud
- spring boot
- docker
- Docker Compose
- WebLogic
- argo cd
- docker compose mysql
- docker-compose
- Netty
- weblogic 10
- vue.js
- redis
- Redis Sentinel
- cassandra
- Selenium
- coalesce
- RabbitMQ
- JPA
Archives
- Today
- Total
IT.FARMER
java throws bubble up 예제 본문
반응형
예외사항을 호출한 메소드에서 처리하고자 하는경우 예외 사항을 상위로 올려준다.
import com.aereport.adtect.common.exception.custom.AEBaseException;
import com.aereport.adtect.common.exception.custom.APIBaseException;
import lombok.ToString;
import org.junit.Test;
/**
* <pre>
* Description : throws bubble up test
*
*
* </pre>
*
* @author skan
* @version Copyright (C) 2018 by skan. All right reserved.
* @since 2018-11-20
*/
public class ThrowsTest {
@Test
public void test1() throws Exception {
try {
this.serviceTest();
} catch (Exception e) {
if (e instanceof AEBaseException) {
// 저장 실패
return;
} else if (e instanceof APIBaseException) {
System.out.println("APIBaseException");
// API 연동 실패
return;
}
}
}
/**
* 서비스 로직 1
* @throws Exception
*/
public void serviceTest() throws Exception {
this.serviceCommonTest2();
}
/**
* 서비스 로직 2
* @throws Exception
*/
public void serviceCommonTest2() throws Exception {
try {
//TODO
} catch (Exception e) {
throw new AEBaseException();
}
try {
// FIXME 강제 오류
throw new APIBaseException();
} catch (Exception e) {
throw new APIBaseException();
}
}
}
반응형
'JAVA' 카테고리의 다른 글
CompletableFuture (0) | 2019.05.16 |
---|---|
API call back off time(재요청 타시간) (0) | 2019.05.07 |
java 8 stream throw exception bubble up (예외사항 전파) (0) | 2019.05.07 |
linux java 설치 (cent os) update-alternatives (0) | 2019.03.31 |
keytool SSL 사설 인증서 / Spring boot ssl (0) | 2019.03.31 |