You are about to create an exception handling class.
public class MyException extends Exception {}
public class Foo {
public bar() throws MyException {
throw new MyException("try again please");
}
}
I tried it like this. In the compiler,
cannot find symbol: constructor MyException(java.lang.String)
There's an error like this. But isn't the constructor inherited from java.lang.Exception?
The constructor must be newly defined. And you have to call super (message) in the constructor to include the parent constructor. For example,
public class MyException extends Exception {
public MyException(String message) {
super(message);
}
}
You have to do it like this.
918 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.