Try Catch, logging.
- Try/catch powerpoint
- how to do logging, why you want to log errors
- what is the Cutilities.java class?
- errors: class name, line number, error message, exception class name, stack trace.
- try / catch / finally.
- what order do they fire in?
- What is an actual logging framework?
- Logback
- Log4J
- I highly recommend you use an open source library, and don't waste time writing this yourself.
- JForm
- JButton
- JLabel
- ActionListener
- Event based programming.
- try/catch basics - throw number format exceptions from scanner
- print error, stack trace.
- think very critically about what errors mean and how you should log them
- When does it make sense to use finally: closing resources - doing additional Logging. Doing things you ALWAYS want to do.
- If you have a site that gets 100 hits / day and 1 / 1000 hits causes an error you get an error every 10 days.
- If you have a site that gets 1000000 hits a day and 1 / 1000 hits causes an error, you get an error 1000 times per day. What do you do here?
- Data dependent errors are easier to solve with web applications: you can log ids for records and then go look at the data.
Do class demo of the random form.
In java there are two types of exceptions: checked and unchecked. The general rule that you may want to follow is this: if an exception can be expected, and be recovered from by your program, make it checked. If it cannot be recovered from, make it an unchecked exception. Also, keep in mind that all exceptions will implement "throwable".
Check out more detail here. And read Oracle's docs on unchecked exception controversy here.
- RuntimeException
- Error
- NullpointerException
- ArithmeticException
- Exception
- IOException
- XPathException
- SAXException
If you want to make a checked exception, you should extend "Exception" class. If you want to make an unchecked exception you can extend "RuntimeException".