# Ways to Handle Errors in Business Component Programs

The Business Components for Java framework follows the Java platform model for conveying information about run-time errors, so a method can return a result code (also called an error code), throw an exception, or both. Following are some recommendations.

- Use exceptions for serious or unexpected error conditions, use result codes for simple warnings. In general, exceptions are more expensive than result codes: they use more system resources and take longer to process.

- Use an 80/20 rule. If the calling routine is likely to be aware of the condition (for example, end-of-list) roughly 80 percent of the time, return a result code. If callers are likely to be aware 20 percent of the time, throw an exception.

- If stack unwinding will be a serious chore, throw an exception.

The following topics describe how to write error-handling routines:

- Handling Errors Using Error Codes

- Handling Errors through Predefined Business Component Exception Classes

- Trapping Business Component Exceptions on a Client