CodePudding user response:
Which I don't feel better, now that others give us trycatch and throws, that is to say, both of which have the most suitable place, depending on the business to see what you need, usually there is a place dedicated to all exceptions thrown trycatch, directly throws elsewhere, such as spring exceptionhandler is aboutCodePudding user response:
Depending on the specific nor demand, in the framework throws, of course, for a business to try, and then feedback to the frontCodePudding user response:
The ITEM 73 Effective JavaTop method should capture the low-level exceptions thrown, and will capture abnormal translated into can comply with the intention of abnormal layer method, throw again, that is often said the unusual escape,
CodePudding user response:
Think need exception thrown to the outside of the throw, don't need to catch outCodePudding user response:
Try catch used to handle exceptions, throws to outer throws an exception,For backend project controller calls the service call dao layer, layer is generally an exception is thrown outwards, the outermost controller to try and catch catch, and for processing, then return to the front, report user errors after processing
CodePudding user response:
Try catch their processing,Throws exception class is to the JVM
Difference with the JVM process has unusually direct
Terminates
Try catch the abnormal will not end even if run
Will still perform the following code,
CodePudding user response:
Let me put it this way, if it is a try catch it generally is a procedure in writing directly will throw exceptions, but there is no direct throw an exception if throws is refers to, abnormal by calling code after people to throw, otherwise it will be an error,CodePudding user response:
Passing by, look at the answers, rarely use the try catchCodePudding user response:
These two kinds of abnormal processing time is different, what specific situation, did not say must be usedCodePudding user response:
Processed by the small white feel yourself Chou has actually had better have a try catch, for other people to do service throwsCodePudding user response:
As the case may be