Handling exceptions

An exception represents an occurrence that, if not handled explicitly within the map, stops the map's execution. During the execution of a map, run-time exceptions can occur. When you define a custom transformation rule, you can use the "Catch Error" function block to trap any run-time exception. Once you catch a particular exception, you can determine how to handle this exception.

Relationship exceptions

When using relationships in a map, several exceptions can occur. All of these exceptions are subclasses of RelationshipRuntimeException. If you are not concerned about the kind of exception, but simply want to catch them all, you can catch RelationshipRuntimeException. Otherwise, you can catch any of the following exceptions for specific cases:

Figure 86 illustrates the relationship run-time exception hierarchy. Any exception you catch automatically catches those that are lower in the hierarchy. However, if an exception lower in the hierarchy is thrown, you cannot know exactly which one it is unless you catch it specifically.

Figure 86. Relationship run-time exceptions

Example: If you catch RelationshipRuntimeUserErrorException, you automatically also catch RelationshipRuntimeMetaDataErrorException and RelationshipRuntimeGeneralUserErrorException. However, you cannot easily know which one of these was actually thrown, unless you test the exception with the instance of operator. The exception you choose to catch depends on how specific you want your exception handling to be.

Example: Handling duplicate relationship instance IDs

When you add a participant to an identity relationship using the addMyChildren() or create() methods, RelationshipRuntimeDuplicateIdentityEntryException is thrown if you pass a relationship instance ID that already exists. This exception also provides a method, getInstanceId(), to retrieve the relationship instance ID that caused the duplication.

Example: The following example shows how you can catch this exception and retrieve the ID.

int instanceId;
 
try
   {
   instanceId = Relationship.create(myParticipantObj);
   }
catch (RelationshipRuntimeDuplicateIdentityEntryException rrdiee)
   {
   /*
   ** There already is a relationship instance with this 
   ** entry, grab the instanceId from the exception
   */
   instanceId = rrdiee.getInstanceId();
   }

Copyright IBM Corp. 2004