示例代码如下
if (input.length != 2) {
logger.error("The input for execute " + component.toString() + " is not right!");
throw new Exception("hehehe");
}
及
if (input.length != 2) {
logger.error("The input for execute " + component.toString() + " is not right!");
throw new Error("hehehe");
}
Exception:
1. Can be controlled (checked) or uncontrollable (unchecked).
2. Indicates an error caused by the programmer.
3. Should be handled at the application level.
Error:
1. Always unchecked.
2. Often used to indicate
系统错误
或底层资源
errors.3. Whenever possible, it should be caught at the system level.
I remember it seems that it will never be used in your program
throw error