Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/34.canada.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Explicitly log Database (and other) Exceptions in the `delete_datastore_table` view function via the `datastore_delete` action. This fixes an issue with ambiguous stacktraces only logging `TypeError` for view function return instead of the parent Exception.
10 changes: 10 additions & 0 deletions ckanext/xloader/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from flask import Blueprint
# (canada fork only): catch all exceptions for explicit logging
from logging import getLogger

# (canada fork only): ckan.plugins.toolkit
from ckan.plugins.toolkit import _, h, g, render, request, abort, NotAuthorized, get_action, ObjectNotFound
Expand All @@ -7,6 +9,8 @@


xloader = Blueprint("xloader", __name__)
# (canada fork only): catch all exceptions for explicit logging
log = getLogger(__name__)


def get_blueprints():
Expand Down Expand Up @@ -47,6 +51,12 @@ def delete_datastore_table(id, resource_id):
"force": True})
except NotAuthorized:
return abort(403, _(u'Unauthorized to delete resource %s') % resource_id)
# (canada fork only): catch all exceptions for explicit logging
# datastore_delete can raise various DB exceptions
except Exception as e:
log.error('Failed to delete DataStore table '
'for Resource %s with errors:\n\n%s' % (resource_id, e))
return abort(500)

h.flash_notice(_(u'DataStore and Data Dictionary deleted for resource %s') % resource_id)

Expand Down
Loading