在编写我之前在这里提到的异常代码时,我来到了消息的结尾,并停顿在标点符号处。我意识到我所抛出的几乎每个异常消息都可能有一个!。
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!!!!!");
在编写异常信息时,您采用什么语气?在查看日志时,您是否发现某些消息样式比其他样式更有帮助?