Results 1 to 3 of 3
- 08-17-2012, 05:49 AM #1
Member
- Join Date
- Aug 2012
- Location
- Tamworth, Australia
- Posts
- 42
- Rep Power
- 0
Question about exception handling - Help needed
Hi,
Could someone please breifly explain to me how I can handle exceptions from multiple classes, I cant find anything on the Internet that uses multiple classes.
This is my catch statement to handle the exception within my Main program (below), however I want to handle an exception from another class. I understand I could use the .getMessage, but I have three classes and Im thinking this method will only work with one?
Could someone please explain this to me?
Catch within my Main program:
Java Code:catch (Exception e) { System.err.println("Error: This is the Exception"); }
Thanks,
Ben
- 08-17-2012, 07:12 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Question about exception handling - Help needed
I'm not sure what exactly do you want to do and what`s your question

You can catch several exceptions and you can treat them differently
In some cases, you want to do the same (e.g. logging the exception) in both cases, since Java 7 there is a multiple catchJava Code:catch ( SQLException e ) { ... } catch ( IOException e ) { .... }
If this doesn`t answer your question, maybe this helps: Lesson: Exceptions (The Java™ Tutorials > Essential Classes)Java Code:catch ( SQLException | IOException e ) { .... }
- 08-17-2012, 10:40 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
Exception handling question
By BenH in forum Advanced JavaReplies: 1Last Post: 05-21-2012, 11:13 PM -
Question about Exception handling
By bigsonny in forum New To JavaReplies: 26Last Post: 08-05-2011, 12:28 AM -
Exception Handling
By link6790 in forum New To JavaReplies: 16Last Post: 05-19-2011, 06:57 PM -
Handling long strings - Advice needed
By Codercode in forum Forum LobbyReplies: 0Last Post: 01-02-2011, 12:43 AM -
Handling Exception - elementary question
By kracer in forum New To JavaReplies: 2Last Post: 05-06-2010, 11:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks