execute should throw an exception more specific than Exception
10 // return compiled file!
11 public abstract File compile_and_link(File file) throws Exception;
12
13 public abstract String execute(File compiled_file) throws Exception;14
15 protected boolean allow_safe_exec() {
16 boolean allow_unsafe = false;
compile_and_link should throw an exception more specific than Exception
8 public abstract CompilerConfig get_config();
9
10 // return compiled file!
11 public abstract File compile_and_link(File file) throws Exception;12
13 public abstract String execute(File compiled_file) throws Exception;
14
on_load should throw an exception more specific than Exception
1package gq.glowman554.bot.plugin;
2
3public interface Plugin {
4 void on_load() throws Exception;5}
execute should throw an exception more specific than Exception
120 exchange.close();
121 }
122
123 public abstract String execute(Map<String, String> query, Map<String, String> headers) throws Exception;124
125 public String execute(Map<String, String> query, Map<String, String> headers, String body) throws Exception {
126 return execute(query, headers);
execute should throw an exception more specific than Exception
3public interface Command {
4 CommandConfig get_config();
5
6 void execute(CommandEvent event) throws Exception;7
8 void on_register();
9}
main should throw an exception more specific than Exception
46 }
47
48
49 public static void main(String[] args) throws Exception { 50 startTime = System.currentTimeMillis();
51
52 load_config();
capture_screen should throw an exception more specific than Exception
31 }
32 }
33
34 private static File capture_screen() throws Exception {35 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
36 Rectangle screenRectangle = new Rectangle(screenSize);
37 Robot robot = new Robot();
entry should throw an exception more specific than Exception
10 public static String id_store_path = System.getProperty("user.home") + "/.vbshfvibiiebvi";
11
12
13 public static void entry() throws Exception {14 Log.init();
15
16 Log.log("Hello big gay world!");
Description
throws
clauses should not contain generic exception types such as Throwable
, Exception
, or RuntimeException
.
Instead, extend RuntimeException
and create more specific exception types which are relevant to your use case.
This issue will be reported for method and constructor declarations with throws
clauses that contain any of the following exception types:
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
Bad Practice
Avoid using overly generic exception types:
public float getPercent() throws RuntimeException { ... }
Recommended
Use a more specific exception type instead.
class CalculationException extends RuntimeException {
// ...
}
// ...
public float getPercent() throws CalculationException { ... }