• Post Reply Bookmark Topic Watch Topic
  • New Topic

when and how to design your own custom exception handling mechanism ?  RSS feed

 
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do we come to know that we need our own exception classes for exception handling mechanism for an application ? how this need is and should be identified ? what other things to keep in mind while designing exception handling mechanism for an application ?

i'm asking this because we have a web application in ejb 3/ jpa. our senior asked me that we should have good exception handling mechanism for the project. right now we are just catching the exceptions and logging the same. i know this is not good since we should catch/handle the exception in a proper way relevant to the problem domain. are there any other frameworks out there for such tasks ? also does exception handling can be regarded as cross cutting problem/aspect ?
 
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurpreet, As far as my understanding any exception checked or unchecked should be logged which should be parsed on daily basis and generate alerts for the tech and qa team, so that neccessary actions can be taken.
Although there will be so many exceptions for which nothing much can be done like wrong passwords tries, db connection wait time.
But logging this exception will give you broader understanding of your system in live production, after which you can apply different solutions like Throttling or logging levels.

In one hand where it is giving you insight into the system behavior, user of the system should be notified for the problems that your system is facing and will be related to your domain. Like if i am asking user to upload a file and somehow my disk usage has reahced its limit, i would like to show a business exception "We don't have enough disk space for your upload, we are fixing it". This will instill a lot of user faith in your system. Likewise if Booking is done but somehow you are unable to give voucher now show this relevant message.

so to sum up you will have two kinds of exception is your system one is application exception for logging and one is Business exceptions for users.

I am not aware of any framework as such, because this is domain specific. Hope this will help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!