commit a96e632bf5dbc95dc361c9a66d7485c8b19ba963
Author: Akihiro Motoki <email address hidden>
Date: Sat Nov 11 18:43:46 2017 +0000
Avoid duplicated message in Batch/DeleteAction
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.
Reviewed: https:/ /review. openstack. org/521382 /git.openstack. org/cgit/ openstack/ horizon/ commit/ ?id=a96e632bf5d bc95dc361c9a66d 7485c8b19ba963
Committed: https:/
Submitter: Zuul
Branch: master
commit a96e632bf5dbc95 dc361c9a66d7485 c8b19ba963
Author: Akihiro Motoki <email address hidden>
Date: Sat Nov 11 18:43:46 2017 +0000
Avoid duplicated message in Batch/DeleteAction
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 .handle( ). In individual BatchAction instances, ption, and then BatchAction. handle( ) skips to show an
BatchAction
handle() method can now show a custom error message and raise an
HandledExce
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: handle( ).
exceptions. handle( request, msg, escalate=True)
<do something>
except Exception as e:
# HandledException which wrapps the original exception will be raised.
# HandledException will be caught by BatchAction.
To make it easier to use the pattern, a new decorator tables. actions. handle_ exception_ with_detail_ message is introduced.
horizon.
Partial-Bug: #1733207 6ecd2e30c03edde cee62ff9b13
Change-Id: I4bb0f61c7b63ea