Thursday, July 23, 2009

Exception Handling - Code for failures - Part-2

Part-1 is here...
Part-3 is here...
Exception can be thrown for two reasons
1. Application failure, which includes operational failures, code issues and all other technical issues. (mostly non recoverable by end user)

2. Business validations. (mostly recoverable by end user by changing the input data)

If any failure happened,
we required below information to fix the issue

1. What was the failure?
2. Where it happened?
3. Which circumstance or state or environment?
4. What are the input data?
5. Is this recoverable?
6. Is it necessary to Alert / Escalate to the support people?

Our Exception handling must provide all these details whenever the failure happened.

How do we provide these information?

1. What was the failure?
Do not throw a generic high level exception, provide a more specific Exception class.

2. Where it happened?
Do not throw a generic high level exception, provide a more specific Exception class, if we use the Same exception class in many places differentiates with the Id or message. so we know exactly where the failure happened.

3. Which circumstance or state or environment?
This is very important, many time we programmers do not mind that our program work only in a Conditional state(or environment), so we need to provide this information while throwing exception by id orMessage.

The exception handler (typically a catch block or caller method) would change the state or look foralternate and re-try before throw the exception.

4. What are the input data?
This information is important for Exception handling, most of the time exception could happened by theinput data, throw proper data exception when the failure happened like NullArgumentException

5. Is this recoverable?
Most of the time, we throw Validation Exceptions, these validation exceptions would be recoverable by the end user, so the handling code must know that these exceptions are recoverable exceptions, so we Provide more meaningful information to recover this to the end user.

Secondly this would use to hold the same state or environment for the end user to continue working with the application.

6. Is it necessary to Alert / Escalate to the support people?
Not all the exceptions required admin or support people to be informed, so providing this information to the handler code will alert the admin or support team accordingly.

If we get all the mentioned information without seeing the log, code and trace is consider the better Exception handling.

The Exception handling tips Will be continued…


Anonymous said...

Approvingly your article helped me truly much in my college assignment. Hats off to you send, wish look progressive for the duration of more interrelated articles without delay as its united of my choice question to read.

javaPuru said...

Hi, The 3rd part in this exception handling also written already please find the link here

Anonymous said...

Thanks for an idea, you sparked at thought from a angle I hadn’t given thoguht to yet. Now lets see if I can do something with it.

netbeans said...

this finishes the reading on exception handling, thanks a lot

louis vuitton outlet said...

Tory Burch Outlet
Michael Kors Outlet Ralph Lauren Outlet Gucci Factory Outlet Gucci Outlet Gucci Handbags Cheap Ray Ban Sunglasses North Face Jackets Prada Outlet Burberry Outlet Hollister Clothing Ferragamo Shoes Tiffany Jewelry Tiffany Outlet NFL Jerseys Cheap Jordans Oakley Outlet North Face Outlet Burberry Outlet Ray Ban Sunglasses
Chan Luu Sale Toms Outlet Burberry Outlet Oakley Sunglasses Toms Shoes Sale Beats By Dr Dre Coach Outlet Christian Louboutin Shoes Oakley Sunglasses Valentino Shoes
Oakley Eyeglasses Michael Kors Outlet Coach Factory Outlet Coach Outlet Online Coach Purses Kate Spade Outlet Toms Shoes North Face Outlet Coach Outlet Gucci Belt

Cran Kate said...

Burberry Belt Tory Burch Boots Louis Vuitton Belt Ferragamo Belt Marc Jacobs Handbags Lululemon Outlet Christian Louboutin Shoes True Religion Outlet Tommy Hilfiger Outlet
Michael Kors Outlet Coach Outlet Red Bottoms Kevin Durant Shoes New Balance Outlet Adidas Outlet Coach Outlet Online Stephen Curry Jersey Vans Outlet Ralph Lauren Outlet
Ugg Boots Sale UGGS For Women Skechers Go Walk Adidas Yeezy Boost Adidas Yeezy Adidas NMD Coach Outlet North Face Outlet Ralph Lauren Outlet Puma Outlet Polo Outlet
Under Armour Outlet Under Armour Hoodies Herve Leger MCM Belt Nike Air Max Louboutin Heels Jordan Retro 11 Converse Outlet Nike Roshe Run UGGS Outlet North Face Outlet

chenzhen said...

red bottoms outlet online
birkenstock shoes
oakley sunglasses cheap
gucci borse
skechers outlet
versace sunglasses
louis vuitton handbags
jimmy choo outlet store
michael kors bags
kate spade outlet online
hollister clothing store
designer handbags wholesale
nike shoes for cheap
adidas pure boost black
reebok classic
michael kors outlet
oakley sunglasses outlet
michael kors outlet online
coach factory outlet
true religion uk
coach outlet online
tiffany uk
jimmy choo
north face outlet
dolce and gabbana outlet online
nike running shoes
ecco outlet
cheap ray ban sunglasses
coach outlet store
under armour
oakley sunglasses outlet
nike air max 90
louis vuitton uk
chi flat iron
cheap ray bans
pandora jewelry
pandora charms uk
michael kors outlet clearance
burberry outlet canada

Meiqing Xu said...

adidas nmd
beats by dr dre
yeezy boost
michael kors outlet
lebron james shoes 2017
true religion outlet
philadelphia phillies jerseys
mbt shoes
kate spade handbags

Unknown said...

RBSE Result 2017
Karnataka 2nd PUC Result 2017
PSEB Result 2017
Maharashtra SSC Board Result 2017

Nilesh sharma said...

Kerala DHSE +2 Result 2017
MP Board 12th Result 2017
Maharashtra Board HSC Result 2017
UP 12th Class Result 2017
Odisha CHSE Result 2017

boss patel said...

UP Board highschool result 2017
ISC Exam Result 2017
sslc result 2017
Bihar Board 12th Result 2017 hsc 2017

suhail alam said...

Ramadan Mubarak Message in urdu hindi english
Ramadan Mubarak image Wallpaper 2017
Ramadan sms wishes 2017
Ramadan status for whatsapp facebook
Happy Fathers day 2017
Fathers day quotes 2017
Fathers day image 2017

suhail alam said...

Memorial day 2017
Memorial day image 2017
Memorial day quotes saying 2017
Memorial day message 2017
Memorial day quotes
Happy Ramadan Mubarak 2017
Happy Ramadan message 2017
Ramadan Mubarak Image 2017

suhail alam said...

Happy Mothers day poems and songs
Happy Mothers day animated gif image
Happy Mothers day lyrics songs
Best Mothers day Present Ideas gift ideas
Mothers day wishing message quotes sms
Mothers day craft 2017
Mothers day whatsapp status 2017
Mothers day image & Wallpaper 2017
Mothers day outfits dress

suhail alam said...

Mothers day wishes 2017
Happy Mothers day 2017 poems
Happy Mothers day 2017
Happy Mothers day Message from daughter
Happy Mothers day sms wishes
Happy Mothers day quotes saying
Happy Mothers day greeting cards
Happy Mothers day Picture Image

ninest123 said...

yeezy boost
adidas yeezy
fendi handbags
adidas nmd
birkenstock outlet
pandora jewelry
longchamp outlet
birkenstock shoes
red bottoms

Tamanna Akter said...

Its my first visit to your blog and i have found it so useful and informative
specially this post. I have bookmarked it and I am looking forward to reading new posts. Thanks for sharing. Keep up the good work.
hsc result 2017
hsc result 2017 bd
HSC Result 2017 By SMS