Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I find out what a certain error is caused by?

easy debugging

How do I find out what a certain error is caused by?

by  carpeliam  Posted    (Edited  )
If you're using a system that uses breakpoints, it can be rather easy to find out where errors are coming from. If you find out that a particular line is creating an error, put it in a try block like this:

[tt]try {
// this line throws an exception
} catch (Exception e) {
System.out.println();
}[/tt]

Put a break point at the [tt]System.out.println()[/tt] line. From there, you can determine the values of all relative variables, and get a better idea of where your bug is coming from.

If your SDK doesn't have breakpoints, don't fret too much. Do the same thing, except in your [tt]System.out.println()[/tt], print out the values of any variables that might be pertinent. you might want to also call e.printStackTrace() to receive the stack trace (this is printed out in any case when the exception is not caught). Happy debugging!

Liam Morley
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top