+# -*- coding: utf-8 -*-
+# This file is part of django-ssify, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See README.md for more information.
+#
+"""
+Exception classes used in django-ssify.
+"""
+from __future__ import unicode_literals
+from django.utils.encoding import python_2_unicode_compatible
+
+
+class RequestMixin(object):
+ """Lets us print request and view data in the exceptions messages."""
+
+ def __init__(self, request, *args):
+ self.request = request
+ super(RequestMixin, self).__init__(*args)
+
+ def view_path(self):
+ """Returns full Python path to the view used in the request."""
+ try:
+ view = self.request.resolver_match.func
+ return "%s.%s" % (view.__module__, view.__name__)
+ except AttributeError:
+ return "<unknown>"
+
+
+class SsifyError(RequestMixin, BaseException):
+ """Base class for all the errors."""