Last active
August 29, 2015 13:57
-
-
Save tokiwoousaka/9783721 to your computer and use it in GitHub Desktop.
"@zakky_dev: Aの処理に失敗したらBをやり、それにも失敗したらCをやり、そこで失敗したら例外をスローする。どの処理でも成功したらDの処理を実行する。こういったことやりたいのかなりあるんだけど、どうしよっかなー。" https://twitter.com/zakky_dev/status/448654622970753024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
private static void procces(boolean success, String procName){ | |
if(success){ | |
System.out.println("処理 " + procName + " 成功"); | |
throw new RuntimeException(); | |
} | |
System.out.println("処理 " + procName + " 失敗。。。"); | |
} | |
public static void run(){ | |
try{ | |
procces(false, "A"); | |
procces(true, "B"); | |
procces(false, "C"); | |
}catch(Exception ex){ | |
System.out.println("処理 D 実行"); | |
return; | |
} | |
throw new RuntimeException("全部失敗したよ!"); | |
} | |
public static void main(String[] args) { | |
run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
正直すまんかった。