When writing code that throws an exception, which I asked about here , I came to the end of my post and settled on punctuation. I realized that almost every exception message I've ever thrown may have! somewhere.
throw new InvalidOperationException("I'm not configured correctly!"); throw new ArgumentNullException("You passed a null!"); throw new StupidUserException("You can't divide by 0! What the hell were you THINKING??? DUMMY!!!!!");
What tone do you take when writing exception messages? When you look through the logs, you find that a certain message style really helps more than another?
. , .
, Java , , . , " ", . , , , (, , , ..).
, , :
throw new IndexOutOfBoundsException("offset < 0: " + off);
. , , .
, , - , - , . , , .
, , . , , , - , .
(UI ), , () .
, , , .
" , , ?" "- . , , , , - . , ".
, (.. ArgumentNullException, , ).
, , .
. , , " !" " , ".;)
, , . , , . , :
throw new MagicalException(getText("magical.exception.text"));
( ) . .
, . -, - .
:
Error 203 (Timeout) in commit.c line 42: Unable to save salary data for user 'Linus' to database at '10.10.1.21' after 1500ms. Verify database address and login credentials.
, , , , . , , .
, , . . file_not_found " ". , ; , . , , .
, , , . , , .