I'm just trying to understand my understanding of the exception mechanism. If something goes wrong when the application is executed, the runtime automatically throws an appropriate exception. If so, why should I sometimes check and explicitly throw a specific exception?How to determine such cases (when an exception should be explicitly introduced into the code)?
I did not set any example here specifically, because I would like to get a general idea of ββthe method of eliminating exceptions.
, Fail Fast - , , , , "" ( / ).
, , , , , .
, , , , , , , . , , , , null, <ArgumentNullException
null
ArgumentNullException
, , , , , ( ) , .
", ", , . , SaveFile(), , , , , , ... SaveFile() - , , .
, ,
/ , - ( foos n , )
, , , ( , , ( , , ..), , .
, .. , / ..
, - . ( "x null!" - , ). , - , . . , (java,.net), , ( , , ,...), , .
: , , . NPE - , .
( , void, int, string, car ..) , T, Exception, "- ". , , ( , SQLException) . ( ) .