mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Remove ConfigurationError in favor of Django's ImproperlyConfigured
This commit is contained in:
parent
2ca243a114
commit
f8a0d31d71
|
@ -86,10 +86,3 @@ class Throttled(APIException):
|
|||
self.detail = format % (self.wait, self.wait != 1 and 's' or '')
|
||||
else:
|
||||
self.detail = detail or self.default_detail
|
||||
|
||||
|
||||
class ConfigurationError(Exception):
|
||||
"""
|
||||
Indicates an internal server error.
|
||||
"""
|
||||
pass
|
||||
|
|
|
@ -285,7 +285,7 @@ class GenericAPIView(views.APIView):
|
|||
)
|
||||
filter_kwargs = {self.slug_field: slug}
|
||||
else:
|
||||
raise exceptions.ConfigurationError(
|
||||
raise ImproperlyConfigured(
|
||||
'Expected view %s to be called with a URL keyword argument '
|
||||
'named "%s". Fix your URL conf, or set the `.lookup_field` '
|
||||
'attribute on the view correctly.' %
|
||||
|
|
|
@ -11,6 +11,7 @@ from __future__ import unicode_literals
|
|||
import copy
|
||||
import json
|
||||
from django import forms
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.template import RequestContext, loader, Template
|
||||
from django.utils.xmlutils import SimplerXMLGenerator
|
||||
|
@ -18,7 +19,6 @@ from rest_framework.compat import StringIO
|
|||
from rest_framework.compat import six
|
||||
from rest_framework.compat import smart_text
|
||||
from rest_framework.compat import yaml
|
||||
from rest_framework.exceptions import ConfigurationError
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.request import clone_request
|
||||
from rest_framework.utils import encoders
|
||||
|
@ -270,7 +270,7 @@ class TemplateHTMLRenderer(BaseRenderer):
|
|||
return [self.template_name]
|
||||
elif hasattr(view, 'get_template_names'):
|
||||
return view.get_template_names()
|
||||
raise ConfigurationError('Returned a template response with no template_name')
|
||||
raise ImproperlyConfigured('Returned a template response with no template_name')
|
||||
|
||||
def get_exception_template(self, response):
|
||||
template_names = [name % {'status_code': response.status_code}
|
||||
|
|
|
@ -3,7 +3,7 @@ Provides various throttling policies.
|
|||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.core.cache import cache
|
||||
from rest_framework import exceptions
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from rest_framework.settings import api_settings
|
||||
import time
|
||||
|
||||
|
@ -65,13 +65,13 @@ class SimpleRateThrottle(BaseThrottle):
|
|||
if not getattr(self, 'scope', None):
|
||||
msg = ("You must set either `.scope` or `.rate` for '%s' throttle" %
|
||||
self.__class__.__name__)
|
||||
raise exceptions.ConfigurationError(msg)
|
||||
raise ImproperlyConfigured(msg)
|
||||
|
||||
try:
|
||||
return self.settings.DEFAULT_THROTTLE_RATES[self.scope]
|
||||
except KeyError:
|
||||
msg = "No default throttle rate set for '%s' scope" % self.scope
|
||||
raise exceptions.ConfigurationError(msg)
|
||||
raise ImproperlyConfigured(msg)
|
||||
|
||||
def parse_rate(self, rate):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user