Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: chrome/common/extensions/docs/server2/api_data_source.py

Issue 10830252: Extensions Docs Server: Uniform handling of file not found errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/api_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 5e07ea25b0e763abe88890d40f2cd9db9bda4b96..2df100b778898d4ab092d48eb27923e56d567ea4 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -3,9 +3,9 @@
# found in the LICENSE file.
import json
-import logging
import os
+from file_system import FileNotFoundError
from handlebar_dict_generator import HandlebarDictGenerator
import third_party.json_schema_compiler.json_comment_eater as json_comment_eater
import third_party.json_schema_compiler.model as model
@@ -60,12 +60,14 @@ class APIDataSource(object):
try:
perms = self._permissions_cache.GetFromFile(
self._base_path + '/_permission_features.json')
- api_perms = perms.get(path, None)
- if api_perms['channel'] == 'dev':
- api_perms['dev'] = True
- return api_perms
- except Exception:
+ except FileNotFoundError:
return None
+ api_perms = perms.get(path, None)
+ if api_perms is None:
+ return None
+ if api_perms['channel'] == 'dev':
+ api_perms['dev'] = True
+ return api_perms
def _GenerateHandlebarContext(self, api_name, handlebar, path):
return_dict = { 'permissions': self._GetFeature(path) }
@@ -90,10 +92,7 @@ class APIDataSource(object):
return self._GenerateHandlebarContext(key,
self._json_cache.GetFromFile(self._base_path + '/' + json_path),
path)
- except OSError:
- try:
- return self._GenerateHandlebarContext(key,
- self._idl_cache.GetFromFile(self._base_path + '/' + idl_path),
- path)
- except OSError as e:
- raise
+ except FileNotFoundError:
+ return self._GenerateHandlebarContext(key,
+ self._idl_cache.GetFromFile(self._base_path + '/' + idl_path),
+ path)
not at google - send to devlin 2012/08/10 06:12:16 not sure, perhaps this should also be catching Fil
cduvall 2012/08/10 17:25:16 I would rather have it throw the exception than re
not at google - send to devlin 2012/08/12 22:22:58 Ok sg. Makes me wonder if there are other things (
cduvall 2012/08/13 18:44:05 Done.

Powered by Google App Engine
This is Rietveld 408576698