Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Commit

Permalink
logging the request and the user on the error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Navarro Bosch committed Jan 22, 2017
1 parent df08d94 commit 7ba0a9e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/plone.server/plone/server/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from plone.server.transactions import commit
from plone.server.utils import apply_cors
from plone.server.utils import import_class
from plone.server.utils import get_authenticated_user_id
from zope.component import getUtility
from zope.component import queryMultiAdapter
from zope.component.interfaces import ISite
Expand Down Expand Up @@ -153,19 +154,31 @@ def generate_unauthorized_response(e, request):
# We may need to check the roles of the users to show the real error
eid = uuid.uuid4().hex
message = _('Not authorized to render operation') + ' ' + eid
user = get_authenticated_user_id(request)
extra = {
'r': request.url.human_repr(),
'u': user
}
logger.error(
message,
exc_info=e)
exc_info=e,
extra=extra)
return UnauthorizedResponse(message)


def generate_error_response(e, request, error, status=400):
# We may need to check the roles of the users to show the real error
eid = uuid.uuid4().hex
message = _('Error on execution of view') + ' ' + eid
user = get_authenticated_user_id(request)
extra = {
'r': request.url.human_repr(),
'u': user
}
logger.error(
message,
exc_info=e)
exc_info=e,
extra=extra)

return ErrorResponse(
error,
Expand Down

0 comments on commit 7ba0a9e

Please sign in to comment.