# Java: Error processing

## Error in user input or action

Allow user to recover. If the user makes an error in input, give appropriate feedback and allow them to correct the error if possible.

Informative message. It's important to give specific feedback that allows them to correct their problem. I recently used a program that produced an "Error in processing" error message. There was no hint as to whether is was my error or a bug in the program. Bad.

## Debugging error checking - assert

Use `assert` statements liberally to debug your own code. See Assertions. Assertions are very easy to use and are very helpful during testing. You can leave them in your final code.

Off at runtime. The disadvantage of assertions is that they are turned off by default during execution. Try to run with them turned on if possible. Some programmers think it's an advantage that they're off at runtime -- there is no execution overhead, and the user won't be faced with potentially puzzling messages.

## Programmer errors - throw an exception

If you write code that is going to be used by other programmers, it is especially important to detect errors and throw an exception. Exceptions - More, altho quite incomplete, has an example using `IllegalArgumentException` that might be useful.