summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--designate/api/middleware.py5
-rw-r--r--designate/api/v2/__init__.py6
-rw-r--r--designate/api/v2/controllers/root.py9
-rw-r--r--designate/exceptions.py1
4 files changed, 18 insertions, 3 deletions
diff --git a/designate/api/middleware.py b/designate/api/middleware.py
index d32531ad..42461277 100644
--- a/designate/api/middleware.py
+++ b/designate/api/middleware.py
@@ -223,8 +223,9 @@ class FaultWrapperMiddleware(wsgi.Middleware):
return self._handle_exception(request, e)
def _handle_exception(self, request, e, status=500, response={}):
- # Log the exception ASAP
- LOG.exception(e)
+ # Log the exception ASAP unless it is a 404 Not Found
+ if not getattr(e, 'expected', False):
+ LOG.exception(e)
headers = [
('Content-Type', 'application/json'),
diff --git a/designate/api/v2/__init__.py b/designate/api/v2/__init__.py
index 8f3c0622..826f3b62 100644
--- a/designate/api/v2/__init__.py
+++ b/designate/api/v2/__init__.py
@@ -33,7 +33,11 @@ def factory(global_config, **local_conf):
conf = {
'app': {
'root': 'designate.api.v2.controllers.root.RootController',
- 'modules': ['designate.api.v2']
+ 'modules': ['designate.api.v2'],
+ 'errors': {
+ 404: '/not_found',
+ '__force_dict__' : True
+ }
}
}
diff --git a/designate/api/v2/controllers/root.py b/designate/api/v2/controllers/root.py
index d989ff89..d7e2d73d 100644
--- a/designate/api/v2/controllers/root.py
+++ b/designate/api/v2/controllers/root.py
@@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+from designate import exceptions
from designate.openstack.common import log as logging
from designate.api.v2.controllers import limits
from designate.api.v2.controllers import reverse
@@ -21,6 +22,8 @@ from designate.api.v2.controllers import tlds
from designate.api.v2.controllers import zones
from designate.api.v2.controllers import blacklists
+from pecan import expose
+
LOG = logging.getLogger(__name__)
@@ -35,3 +38,9 @@ class RootController(object):
tlds = tlds.TldsController()
zones = zones.ZonesController()
blacklists = blacklists.BlacklistsController()
+
+ @expose(content_type='text/plain')
+ @expose(content_type='text/dns')
+ @expose(content_type='application/json')
+ def not_found(self):
+ raise exceptions.NotFound
diff --git a/designate/exceptions.py b/designate/exceptions.py
index c2cdd42a..32801282 100644
--- a/designate/exceptions.py
+++ b/designate/exceptions.py
@@ -197,6 +197,7 @@ class DuplicateBlacklist(Duplicate):
class NotFound(Base):
+ expected = True
error_code = 404
error_type = 'not_found'