def delete(self, request, *args, **kwargs):
        try:
            result = super(SingleObjectDeleteView, self).delete(request, *args, **kwargs)
        except Exception as exception:
            try:
                messages.error(
                    self.request,
                    _('Error deleting %s.') % self.extra_context['object_name']
                )
            except KeyError:
                messages.error(
                    self.request, _('Error deleting object.')
                )

            raise exception
        else:
            try:
                messages.success(
                    self.request,
                    _(
                        '%s deleted successfully.'
                    ) % self.extra_context['object_name']
                )
            except __HOLE__:
                messages.success(
                    self.request, _('Object deleted successfully.')
                )

            return result
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/common/generics.py/SingleObjectDeleteView.delete