Effective Exception Handling using Java, a Simple Tutorial
Last updated: 2025-09-14
Steps:
-
Create Maven project with the following pom.xml:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-core/java-util-exception-handling-tutorial.adoc - include::inc/pom.xml[]
If you are using Eclipse, be sure to refresh your project (select your project→ right click→ Maven→ Update Project) |
Default Exception Handler
-
Create ExceptionExample1 class with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-core/java-util-exception-handling-tutorial.adoc - include::inc/src/main/java/com/app/exception/ExceptionExample1.java[]
Thats it, now run your ExceptionExample2 class, and you should see something line this:

Custom Exception Handler
-
Create CustomExceptionHandler class with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-core/java-util-exception-handling-tutorial.adoc - include::inc/src/main/java/com/app/exception/CustomExceptionHandler.java[]
-
Create ExceptionExample2 class with the following contents:
Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-core/java-util-exception-handling-tutorial.adoc - include::inc/src/main/java/com/app/exception/ExceptionExample2.java[]
Thats it, now run your ExceptionExample2 class, and you should see something line this:

Full example source-code can be found at https://github.com/smartapi-com/j-framework-util |