Added DocumentNotFoundError

This commit is contained in:
Jacob Mason 2010-07-30 15:53:02 -05:00
parent f014641405
commit 846ab3a743
2 changed files with 10 additions and 1 deletions

View File

@ -22,6 +22,7 @@ from sphinx.application import Sphinx
from sphinx.util.osutil import ensuredir
from sphinx.websupport.search import BaseSearch, search_adapters
from sphinx.websupport.comments import StorageBackend
from sphinx.websupport.errors import DocumentNotFoundError
class WebSupportApp(Sphinx):
def __init__(self, *args, **kwargs):
@ -126,7 +127,13 @@ class WebSupport(object):
:param docname: the name of the document to load.
"""
infilename = path.join(self.outdir, docname + '.fpickle')
f = open(infilename, 'rb')
try:
f = open(infilename, 'rb')
except IOError:
raise DocumentNotFoundError(
'The document "%s" could not be found' % docname)
document = pickle.load(f)
return document

View File

@ -13,6 +13,7 @@ import os
from StringIO import StringIO
from sphinx.websupport import WebSupport
from sphinx.websupport.errors import DocumentNotFoundError
try:
from functools import wraps
@ -44,4 +45,5 @@ def with_support(*args, **kwargs):
@with_support()
def test_build(support):
support.build()
raises(DocumentNotFoundError, support.get_document, 'nonexisting')