pigmentarts
asked on
Is there anyway I can use ‘use case’ for error handling?
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You *could* use a case statement but it would be highly artificial and not a good idea
ASKER
it was just i has seen it somewere i wanted to see if it was just in my head or not. thanks.
Please explain the reason for accepting that particular answer pigmentarts
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
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
catch(Exception e) {
if (e instanceof IOException) {
// do something
}
else if (s instanceof ClassCastException) {
// do something different
}
}