Comment 5 for bug 1733207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/521382
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=a96e632bf5dbc95dc361c9a66d7485c8b19ba963
Submitter: Zuul
Branch: master

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.

    Partial-Bug: #1733207
    Change-Id: I4bb0f61c7b63ea6ecd2e30c03eddecee62ff9b13