18 Handling Errors

This chapter describes how to handle errors that occur when running a business process. Oracle BPM provides you with an exception component that enables you to model errors and multiple BPMN structures that you can use to handle those errors while running the process.

This chapter includes the following sections:

18.1 Introduction to Error Handling

There might be situations where you face an unexpected problem that causes your process to fail. There are two types of errors: system errors and process errors.

System errors are the consequence of a failure in the software or hardware infrastructure where the BPMN Service Engine is running. A system error can have many causes. The following are examples of problems that can cause a system error:

  • a failure in the database connection

  • a connectivity loss

  • a problem with the hard disk

To recover from system errors you can use the fault recovery system provided by Enterprise Manager. See Oracle Fusion Middleware Administrator's Guide for Oracle SOA Suite and Oracle Business Process Management Suite, for more information about the Enterprise Manager fault recovery system.

Process errors are problems that interfere with the regular development of your process. For example, in a purchase order process, if there is no stock for the requested item then you cannot continue with the regular process flow. You can handle these unexpected situations within the process flow. You might handle the situation in this example by offering the customer to cancel the order or save it for later.

The following are typical examples of unexpected situations within a process:

  • lack of stock

  • workload limit exceeded

  • expense limit exceeded

  • feedback past due

  • credit card authentication problems

18.1.1 Handling Business Errors Using Exceptions

Oracle BPM uses business exceptions to represent unexpected situations that may arise while running a business process.

You can design how to handle an exception as part of the business process, but it is something that occurs outside of the normal flow of a process. The use of business exceptions enables you to create cleaner processes where the main flow follows the normal use cases and there is a separate flow to handle the process exception.

Business exceptions are considered a normal part of the process design rather than an error.

When you add a component to the business catalog, if the services in the component specify they can produce errors then these errors appear as business exceptions in the business catalog in the Errors pre-defined module.

An exception can arise when you invoke these services. You can handle these exceptions using a boundary error catch event or an event subprocess.

You can also define business exceptions in the business catalog. Then you can use those business exceptions in an error end event that is triggered under a certain condition. The error end event generates the exception and the parent process can handle the exception.

18.1.2 Typical Flow of an Exception Thrown in a Task

The following sequence describes what happens when the BPMN Service Engine invokes a task that causes an exception.

  1. The BPMN Service Engine runs a task that invokes a service that can throw an exception.

  2. The task fails with a SOAP error that the BPMN Service Engine transforms into an exception.

  3. If the task has a boundary catch error event attached, then the instance follows the flow defined by the boundary catch error event to handle the exception. The exception handling flow may resume the main process flow. If it does not resume the main process flow, then the process ends in the boundary catch error event.

    If the task does not have a boundary catch error event associated, then the exception propagates to the process level.

  4. At the process level, the following options are possible:

    • If the process does not contain an event subprocess that can catch the exception and you did not define a fault policy, then the BPM Service Engine logs this error to the Enterprise Manager fault recovery system. See Oracle Fusion Middleware Administrator's Guide for Oracle SOA Suite and Oracle Business Process Management Suite, for more information about the Enterprise Manager fault recovery system.

    • If the process contains an event subprocess with a start event of type error configured to catch that exception, then the instance continues through the exception handling flow. When the instance completes the exception handling flow the process ends.

18.1.3 Typical Flow of an Exception in a Subprocess

The following sequence describes what happens when the BPMN Service Engine invokes a subprocess that causes an exception.

  1. The BPM Service Engine runs a subprocess that contains a task that invokes a service that can throw an exception or an end error event.

  2. One of the following happens:

    • The task throws an exception.

    • The subprocess ends with an error event.

  3. If the exception occurs in a task and the task has a boundary catch error event or the subprocess contains an event subprocess that can handle the exception, then the exception does not propagated to the parent process.

    If the subprocess ends with an error event, or the exception occurs in a task and is not handled, then the exception propagates to the parent process.

  4. The parent process can handle the exception if:

    • the subprocess has a boundary catch event attached.

    • it contains an event subprocess configured to catch the exception.

    If the parent process cannot handle the exception, then it propagates it to its parent process. If there is no parent process, then the exception is logged to the Enterprise Manager fault recovery system. See Oracle Fusion Middleware Administrator's Guide for Oracle SOA Suite and Oracle Business Process Management Suite, for more information about the Enterprise Manager fault recovery system.

18.2 Handling Exceptions in a Business Process

You can handle the exceptions that arise in an activity using the following:

  • A boundary error catch event

  • An event subprocess

Figure 18-1 Boundary Error Catch Event

Description of Figure 18-1 follows
Description of "Figure 18-1 Boundary Error Catch Event"

Figure 18-2 Event Subprocess With a Start Error Event

Description of Figure 18-2 follows
Description of "Figure 18-2 Event Subprocess With a Start Error Event"

Boundary error catch events allow you to resume the main process flow after handling the exception.

If you want to reuse the exception handling flow for multiple tasks in your process then event subprocesses are more efficient than boundary catch events. Event subprocesses enable you to define a cleaner process with less effort because the catch error event is located within the event subprocess. To reuse an exception handling flow using boundary catch events you must define a boundary catch event for each of the tasks and then connect those boundary events to the exception handling flow.

Event subprocesses also enable you to define data objects that you can access only from within the event subprocess, in the same way that subprocess enable you to define their own data objects.

18.2.1 How to Handle an Exception Using a Boundary Error Catch Event

If you know that running a flow object may cause an exception, then you can design your process to handle the exception using a boundary error catch event.

To handle an exception using a boundary error catch event:

  1. Create an exception handling flow.

    After handling the exception, this flow can resume the main process or end the process.

  2. From the Component Palette, from the Catch Events section select Error Event.

  3. Drop the error event over the task that throws the exception.

    You can place the event in any part of the border of the task.

    When you drop the error event a sequence flow appears that you can connect to the exception handling flow.

  4. Connect the sequence flow to the exception handling flow.

  5. Right-click the boundary catch error event.

  6. Select Properties.

  7. Click the Implementation tab.

  8. If you want to handle all the business exceptions that can occur while running this task, then you must select Catch All Business Exceptions.

    To catch a specific business exception:

    1. Click the Browse button next to the Exception field.

      The Type dialog appears.

    2. Type the name of the exception or select it from the tree.

    3. Click OK.

      The Type dialog closes and the selected exception appears in the Exception field.

  9. Click OK.

18.2.2 What Happens When You Handle an Exception Using a Boundary Catch Event

If the BPMN Service Engine encounters an error while running a task that has a boundary error catch event attached, then it follows the flow defined by the boundary error catch event. The exception handling flow defined by the boundary error catch event can resume the main process flow or end the process.

18.2.3 How to Handle an Exception Using an Event Subprocess

You can use an event subprocess to handle an exception that may arise while running any of the flow objects in your BPMN process.

To handle an exception using an event subprocess:

  1. From the Component Palette, from the Activities section, select Event Subprocess.

  2. Drop the event subprocess in the process.

  3. Right-click the start event of the event subprocess.

  4. Select Properties.

  5. Click the Implementation tab.

  6. From the Implementation Type list select Error.

  7. If you want to handle all the business exceptions that can occur while running this process, then select Catch All Business Exceptions.

    If you want to catch a specific business exception:

    1. Click the Browse button next to the Exception field.

      The Type dialog appears.

    2. Type the name of the exception or select it from the tree.

    3. Click OK.

      The Type dialog closes and the selected exception appears in the Exception field.

18.2.4 What Happens When You Handle an Exception Using an Event Subprocess

If the exception handled in the event subprocess arises while running any of the tasks in the process, then the BPMN Service Engine continues running the exception handling flow defined in the event subprocess.

18.3 Throwing Exceptions in Subprocesses

You can only throw business exceptions using an error end event, thus only parent processes can catch these exceptions.

You can configure your process to throw custom high level exceptions instead of throwing the low level exceptions that arise while running the task. To do this connect the boundary events in your activities to the end event that throws the error, or finish the subprocess event with an error end event.

18.3.1 How to Throw a Business Exception

You can use an error end event to configure your BPMN process to throw a business exception.

To throw a business exception:

  1. Create a business exception.

    See Section 18.3.3, "How to Create a Business Exception" for more information on how to create a business exception.

  2. Identify the point in your process where you want to throw the exception.

  3. Add a gateway to branch the flow of the process.

  4. From the Component Palette, drag an Error End Event and drop it in the process.

  5. Add a sequence flow to link the gateway and the error end event.

  6. Right-click the error end event.

  7. Select Properties.

  8. Click the Implementation tab.

  9. Click the Browse button next to the Exception field.

    The Type dialog appears.

  10. Type the name of the exception or select it from the tree.

  11. Click OK.

    The Type dialog closes and the selected exception appears in the Exception field.

  12. Click OK.

18.3.2 What Happens When You Throw a Business Exception

The BPMN Service Engine interrupts the process and throws the exception to the parent process. If the subprocess has an error catch boundary event attached or the parent process has an event subprocess that can handle the event, then the parent process can handle the exception. Otherwise the parent process throws the exception to its parent process. If it does not have a parent process, then the BPMN Service Engine logs the exception to Enterprise Manager fault handling system.

18.3.3 How to Create a Business Exception

You can create a business exception and use it to implement the error events in your BPMN process.

To create a business exception:

  1. Right-click a module in the Business Catalog.

    If the business catalog does not contain a module, then you must create one.

  2. Select New.

  3. Select Exception.

  4. Enter a name to identify the exception.

  5. Click OK.

    The Business Exception Editor opens.

  6. Optionally, you can modify the ErrorInfo attribute.

    See Section 18.3.5, "How to Configure the ErrorInfo Attribute in a Business Exception" for information on how to modify the ErrorInfo attribute.

18.3.4 What Happens When You Create a Business Exception

The exception appears in the business catalog in the module you selected. You can configure an error end event in your process to throw this exception, or you can configure a boundary error catch event to handle this exception.

18.3.5 How to Configure the ErrorInfo Attribute in a Business Exception

Business exceptions contain an errorinfo attribute that you can use to store relevant information about the situation that provoked the exception. You can use the information in this field to help end users, process developers, and administrators understand the cause of the error.

To configure the ErrorInfo attribute in a business exception:

  1. Open the Business Exception Editor.

  2. In the Attributes section, expand the errorInfo attribute.

  3. Make changes to the errorInfo attribute properties.

    You can modify the following properties:

    • Description

    • Documentation

    • Type

  4. Click Save or close the Business Exception Editor and save the changes.

18.4 Handling Exceptions in Subprocesses

You can handle exceptions that occur in a subprocess in the same way you handle the exceptions in any other BPMN activity.