Previously BatchAction.handle() automatically adds an error message
when handle() method raises an exception. If some custom error message
is shown in handle() method, two error messages will be shown.
This commit allows a special handling for HandledException to
BatchAction.handle(). In individual BatchAction instances,
handle() method can now show a custom error message and raise an
HandledException, and then BatchAction.handle() skips to show an
error message for that. The reason of using HandledException is
because the exception can be raised from exceptions.handle() function
which is commonly used to handle exceptions.
The common pattern in handle() would be:
try:
<do something>
except Exception as e:
# HandledException which wrapps the original exception will be raised.
# HandledException will be caught by BatchAction.handle().
exceptions.handle(request, msg, escalate=True)
To make it easier to use the pattern, a new decorator
horizon.tables.actions.handle_exception_with_detail_message is introduced.
Partial-Bug: #1733207
Change-Id: I4bb0f61c7b63ea6ecd2e30c03eddecee62ff9b13