This provides a local AST transform to ignore all exceptions thrown from a method.
Add the artifact to your build:
repositories {
jcenter()
}
dependencies {
compile 'com.github.danveloper.ast:ignore-exceptions-ast:1.0.0-rc-2'
}
package app
import com.github.danveloper.ast.IgnoreExceptions
class Main {
@IgnoreExceptions // <1>
public static void main(String[] args) {
throw new RuntimeException() // <2>
}
}
- Annotate your method with
@IgnoreExceptions
. - Have your method throw an exception.
Run the code and notice that no exception is thrown!
Likewise, you can use the @Pokemon
annotation (gotta catch 'em all):
package app
import com.github.danveloper.ast.Pokemon
class Main {
@Pokemon
public static void main(String[] args) {
throw new RuntimeException()
}
}
STEAL THIS CODE PL™