Solved

Is there anyway I can use ‘use case’ for error handling?

Posted on 2004-04-16
7
209 Views
Last Modified: 2010-03-31
Is there anyway I can use ‘use case’ for error handling?

I am sure I have read some where that you can use it for example if error the case1 etc, can this be done in java? can anyone show me any examples if it can be done?
0
Comment
Question by:pigmentarts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846751
Maybe you're thinking about this kind of thing?:

catch(Exception e) {
    if (e instanceof IOException) {
        // do something
    }
    else if (s instanceof ClassCastException) {
        // do something different
    }
}
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10846763
try
{
    // your code here
}
catch (IOException ex)
{
   // handle IOException here
}
catch (ClassCastException ex)
{
   // handle ClassCastException here
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846802
You *could* use a case statement but it would be highly artificial and not a good idea
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 10846812
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10846814
it was just i has seen it somewere i wanted to see if it was just in my head or not. thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10846818
Please explain the reason for accepting that particular answer pigmentarts
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10846833
Hi;

Error handling can delt in many ways like if / else & case statements but the real
way you do that in Java is by using try / catch & finally :

try
{
    if(Your Thing) {
    }
    else {
    }
}
catch (YourException e)
{
   // handle your exception here !
}

Here is a tutorial :
http://java.sun.com/docs/books/tutorial/essential/exceptions/

Hope that helps . . .
Javatm

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question