Permalink
Browse files

log instead of fail

  • Loading branch information...
1 parent b755bf4 commit 5599ffd25a156781a29821c3711ded38d27b36de @zalun zalun committed Jan 4, 2011
Showing with 19 additions and 5 deletions.
  1. +18 −4 apps/api/views.py
  2. +1 −1 manage.py
View
@@ -1,13 +1,17 @@
import os
+import commonware.log
from cuddlefish import apiparser
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.conf import settings
+from django.http import Http404
from jetpack.models import SDK
+log = commonware.log.getLogger('f.api')
+
sdks = SDK.objects.all()
if sdks.count() > 0:
MAIN_SDK = sdks[0]
@@ -115,11 +119,21 @@ def module(r, package_name, module_name):
sdk_version = SDKVERSION
doc_file = '.'.join((module_name, 'md'))
- text = open(
- os.path.join(SDKPACKAGESDIR,
- package_name, 'docs', doc_file)).read()
+ doc_path = os.path.join(SDKPACKAGESDIR,
+ package_name, 'docs', doc_file)
+ try:
+ text = open(doc_path).read()
+ except Exception, err:
+ log.error(str(err))
+ raise Http404
+
# changing the tuples to dictionaries
- hunks = list(apiparser.parse_hunks(text))
+ try:
+ hunks = list(apiparser.parse_hunks(text))
+ except Exception, err:
+ log.error(str(err))
+ hunks = [[None,'Sorry. Error in reading the doc']]
+
entities = []
for h in hunks:
# convert JSON to a nice list
View
@@ -13,7 +13,7 @@
site.addsitedir(path('vendor/lib/python'))
site.addsitedir(path('apps'))
site.addsitedir(path('lib'))
-site.addsitedir(path('lib/jetpack-sdk-0.8/python-lib')) # weak sauce
+site.addsitedir(path('lib/addon-sdk-0.9/python-lib')) # weak sauce
# Move the new items to the front of sys.path. (via virtualenv)
new_sys_path = []

0 comments on commit 5599ffd

Please sign in to comment.