简体   繁体   中英

How can I throw an exception in a Java web project that can't be caught and which ends execution?

If I have a function that does not throw an exception in its signature, but which reaches a condition that should stop all execution, is it possible to throw some kind of exception without altering its signature and that of all calling functions? I tried using response.sendError(500,"My Error"), but it occurs to me that that may not stop execution.

For example, I have coded often in PHP to exit + some small output, but I read that that stops the entire server in Java.

抛出RuntimeException或其子类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM