Commit b8cde355 authored by Michal Čihař's avatar Michal Čihař

Add hooks to new error reporting code

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 5f39a03d
......@@ -19,6 +19,7 @@
#
import urllib2
import sys
import urllib
import hashlib
import os.path
......@@ -31,6 +32,7 @@ from django.conf import settings
import weblate
from weblate import appsettings
from weblate.trans.util import report_error
try:
import libravatar # pylint: disable=import-error
......@@ -127,6 +129,10 @@ def get_avatar_image(user, size):
image = download_avatar_image(user, size)
cache.set(cache_key, image)
except IOError as error:
report_error(
error, sys.exc_info(),
extra_data={'avatar': user.username}
)
weblate.logger.error(
'Failed to fetch avatar for %s: %s',
user.username,
......
......@@ -19,6 +19,7 @@
#
import os
import sys
import binascii
from smtplib import SMTPException
......@@ -39,6 +40,7 @@ from social.apps.django_app.default.models import UserSocialAuth
from weblate.lang.models import Language
from weblate.trans.util import get_site_url
from weblate.accounts.avatar import get_user_display
from weblate.trans.util import report_error
import weblate
from weblate.appsettings import ANONYMOUS_USER_NAME, SITE_TITLE
......@@ -50,6 +52,7 @@ def send_mails(mails):
connection.send_messages(mails)
except SMTPException as error:
weblate.logger.error('Failed to send email: %s', error)
report_error(error, sys.exc_info())
def notify_merge_failure(subproject, error, status):
......
......@@ -24,10 +24,12 @@ Base code for machine translation services.
from django.core.cache import cache
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
import sys
import json
import urllib
import urllib2
import weblate
from weblate.trans.util import report_error
class MachineTranslationError(Exception):
......@@ -171,11 +173,13 @@ class MachineTranslation(object):
try:
languages = self.download_languages()
except Exception as exc:
report_error(
exc, sys.exc_info(),
{'mt_url': self.request_url, 'mt_params': self.request_params}
)
weblate.logger.error(
'Failed to fetch languages from %s, using defaults (%s: %s)',
'Failed to fetch languages from %s, using defaults',
self.name,
exc.__class__.__name__,
str(exc)
)
weblate.logger.error(
'Last fetched URL: %s, params: %s',
......@@ -222,11 +226,13 @@ class MachineTranslation(object):
for trans in translations
]
except Exception as exc:
report_error(
exc, sys.exc_info(),
{'mt_url': self.request_url, 'mt_params': self.request_params}
)
weblate.logger.error(
'Failed to fetch translations from %s (%s: %s)',
'Failed to fetch translations from %s',
self.name,
exc.__class__.__name__,
str(exc)
)
weblate.logger.error(
'Last fetched URL: %s, params: %s',
......
......@@ -28,7 +28,7 @@ from django.core.urlresolvers import reverse
from weblate.trans.models import Translation, Dictionary, Change
from weblate.lang.models import Language
from weblate.trans.util import get_site_url
from weblate.trans.util import get_site_url, report_error
from weblate.trans.forms import WordForm, DictUploadForm, LetterForm
from weblate.trans.views.helper import get_project
import weblate
......@@ -165,6 +165,7 @@ def upload_dictionary(request, project, lang):
) % count
)
except Exception as error:
report_error(error, sys.exc_info(), request)
messages.error(
request, _('File upload has failed: %s') % unicode(error)
)
......
......@@ -25,7 +25,9 @@ from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.views.decorators.http import require_POST
from django.http import Http404
import sys
from weblate.trans.util import report_error
from weblate.trans.forms import get_upload_form
from weblate.trans.views.helper import get_translation
......@@ -135,5 +137,6 @@ def upload_translation(request, project, subproject, lang):
messages.error(
request, _('File content merge failed: %s') % unicode(error)
)
report_error(error, sys.exc_info(), request)
return redirect(obj)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment