Created
March 6, 2013 00:06
-
-
Save noahlz/5095589 to your computer and use it in GitHub Desktop.
What did I do in a prior life to have to look at code like this?
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 Result processCommand(Data data) { | |
try { | |
return doStuff(); | |
// fuck it, just catch everything | |
} catch (Exception ex) { | |
String message = ex.getMessage() != null ? message : "LOL OOPS!"; | |
return new Result(message); | |
} | |
} | |
// 1) Why catching all Exceptions? | |
// 2) The code was throwing java.lang.NullPointerException. getMessage() returns null!!! | |
// 3) How about some fucking logging instead of just returnning a useless error message? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BONUS:
Code that throws NPE in
doStuff()
is actually logging code like the following:Guess what happens if any of those params are null?