public class RollbackException
extends com.veeva.vault.sdk.infrastructure.core.BaseRollbackException
For example, a trigger on a parent record causes a nested trigger on a child record to execute. This nested trigger
throws a RollbackException
with a message about the child record, but this message is confusing to the
user who is not directly interacting with the child record. By catching the error in the parent record trigger, you
can present a more contextualized message to the user who is interacting with the parent record.
If the top level-trigger does not catch the RollbackException
and rethrow with a more appropriate
message, the user will see the original error from the lower-level trigger in the Vault Admin-facing error dialog
display.
Note that creating a new instance of the RollbackException will cause the transaction to terminate even if you don't
explicitly throw this exception. However, it is strongly recommended that you follow standard Java programming to
always explicitly throw an exception.
JobService
or NotificationService
, will execute
only when the request transaction completes. This way, you can use a RollbackException
to stop the
transaction if necessary, keeping asynchronous services from executing unintentionally when the transaction is
rolled back.Constructor and Description |
---|
RollbackException(String errorSubtype,
String errorMessage)
Builds the exception.
|
copyId, copyRollback, equals, hashCode
getErrorMessage, getErrorSubtype, getErrorType, getMessage, isOriginatedInThisProcess
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public RollbackException(String errorSubtype, String errorMessage)
errorSubtype
- error code returned to users. We recommend using SCREAMING_SNAKE_CASE, for example,
MISSING_PARAMETER. May be empty, but cannot be null.errorMessage
- error message returned to users, for example, "Missing value for field {field_name}".
May be empty, but cannot be null.Copyright © Veeva Systems 2017–2021. All rights reserved.