|
32 | 32 |
|
33 | 33 | from apiclient.anyjson import simplejson |
34 | 34 | from apiclient import discovery |
| 35 | +from apiclient.errors import HttpError |
35 | 36 | from google.appengine.api import memcache |
36 | 37 | from google.appengine.ext import webapp |
37 | 38 | from google.appengine.ext.webapp import template |
@@ -97,13 +98,20 @@ class ResourceHandler(webapp.RequestHandler): |
97 | 98 |
|
98 | 99 | def get(self, service_name, version, collection): |
99 | 100 | http = httplib2.Http(memcache) |
100 | | - resource = discovery.build(service_name, version, http=http) |
| 101 | + try: |
| 102 | + resource = discovery.build(service_name, version, http=http) |
| 103 | + except: |
| 104 | + return self.error(404) |
101 | 105 | # descend the object path |
102 | 106 | if collection: |
103 | | - path = collection.split('/') |
104 | | - if path: |
105 | | - for method in path: |
106 | | - resource = getattr(resource, method)() |
| 107 | + try: |
| 108 | + path = collection.split('/') |
| 109 | + if path: |
| 110 | + for method in path: |
| 111 | + resource = getattr(resource, method)() |
| 112 | + except: |
| 113 | + return self.error(404) |
| 114 | + |
107 | 115 | page = _render(resource) |
108 | 116 |
|
109 | 117 | collections = [] |
@@ -134,7 +142,7 @@ def main(): |
134 | 142 | (r'/_gadget/', GadgetHandler), |
135 | 143 | (r'/([^\/]*)/([^\/]*)(?:/(.*))?', ResourceHandler), |
136 | 144 | ], |
137 | | - debug=True) |
| 145 | + debug=False) |
138 | 146 | util.run_wsgi_app(application) |
139 | 147 |
|
140 | 148 |
|
|
0 commit comments