0
회사 용 유틸리티 API를 작성 중이며 유틸리티 메서드가 예외를 throw하는 대신 커스텀 빈 Error 객체가 참조로 전달되고 예외 발생시 채워지는 것으로 간주합니다.메서드에서 예외를 throw하는 대신 참조로 Error 객체를 전달하는 것이 좋습니다.
UML 클래스 다이어그램
ABCError
-code: long
-message: String
-throwable: Throwable
-ABCError()
-set(code,message,throwable) : void
-set(code,message) : void
-set(code):void
-set(message):void
-isSet() : boolean
사용법 :
ABCError error = new ABCError();
HttpResponse response = ABCHttpUtils.post(url,headers,parameters,error);
if(!error.isSet()){
//...
}
이 좋은 생각하거나 자바 협약을 코딩 나누기 때문에 나쁜 일인가요?
(답장을보기 전에 수정 된 답변) –