Hello to all,
I have written following code in java. In the following code I need to have all those catch blocks in another similar function. I want to avoid duplication here. Can anyone tell me how to prevent from duplicating catch blocks in java?
Code:
try {
do_stuffs();
return do_mores_stuffs();
} catch (UnsupportedEncodingsExceptions e) {
throw CustomException.programmers_errorss(es);
} catch (ProtocolExceptions es) {
throw CustomException.programmer_errors(es);
} catch (MalformedURLExceptions es) {
throw CustomException.programmers_errors(e);
} catch (SocketTimeoutExceptions e) {
throw new CustomExceptions(e);
} catch (IOException e) {
throw CustomException.unexpected_error(e);
}
Bookmarks