From 81f8865dcd7b6e7407f24878717afa01e4408782 Mon Sep 17 00:00:00 2001 From: Jeffrey Forman Date: Fri, 25 Nov 2011 12:57:39 -0500 Subject: [PATCH] Add error handling when a DNS server is requested that does not exist in the BindServer table. --- binder/bcommon/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/binder/bcommon/views.py b/binder/bcommon/views.py index 9a4cf6d..ca80c91 100644 --- a/binder/bcommon/views.py +++ b/binder/bcommon/views.py @@ -26,8 +26,14 @@ def list_servers(request): def view_server_zones(request, dns_hostname): """ Display the list of DNS zones a particular DNS host provides. """ - this_server = BindServer.objects.get(hostname=dns_hostname) - zone_array = this_server.list_zones() + try: + this_server = BindServer.objects.get(hostname=dns_hostname) + zone_array = this_server.list_zones() + except BindServer.DoesNotExist, err: + return render_to_response('bcommon/list_server_zones.htm', + { 'errors' : "The server %s does not exist in this Binder instance." % dns_hostname }, + context_instance=RequestContext(request)) + if 'errors' in zone_array: return render_to_response('bcommon/list_server_zones.htm', { 'errors' : zone_array['errors'],