Skip to content

Commit bc248aa

Browse files
authored
Merge pull request readthedocs#4814 from invinciblycool/add-exception
Add MkDocsYAMLParseError
2 parents e35e5ff + 1bcc070 commit bc248aa

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

readthedocs/doc_builder/backends/mkdocs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from django.template import loader as template_loader
1616

1717
from readthedocs.doc_builder.base import BaseBuilder
18-
from readthedocs.doc_builder.exceptions import BuildEnvironmentError
18+
from readthedocs.doc_builder.exceptions import MkDocsYAMLParseError
1919
from readthedocs.projects.models import Feature
2020

2121
log = logging.getLogger(__name__)
@@ -99,7 +99,7 @@ def load_yaml_config(self):
9999
if hasattr(exc, 'problem_mark'):
100100
mark = exc.problem_mark
101101
note = ' (line %d, column %d)' % (mark.line + 1, mark.column + 1)
102-
raise BuildEnvironmentError(
102+
raise MkDocsYAMLParseError(
103103
'Your mkdocs.yml could not be loaded, '
104104
'possibly due to a syntax error{note}'.format(note=note)
105105
)

readthedocs/doc_builder/environments.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from .exceptions import (
3838
BuildEnvironmentCreationFailed, BuildEnvironmentError,
3939
BuildEnvironmentException, BuildEnvironmentWarning, BuildTimeoutError,
40-
ProjectBuildsSkippedError, VersionLockedError, YAMLParseError)
40+
ProjectBuildsSkippedError, VersionLockedError, YAMLParseError, MkDocsYAMLParseError)
4141

4242
log = logging.getLogger(__name__)
4343

@@ -438,6 +438,7 @@ class BuildEnvironment(BaseEnvironment):
438438
ProjectBuildsSkippedError,
439439
YAMLParseError,
440440
BuildTimeoutError,
441+
MkDocsYAMLParseError
441442
)
442443

443444
def __init__(self, project=None, version=None, build=None, config=None,

readthedocs/doc_builder/exceptions.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class BuildEnvironmentException(Exception):
10-
1110
message = None
1211
status_code = None
1312

@@ -21,7 +20,6 @@ def get_default_message(self):
2120

2221

2322
class BuildEnvironmentError(BuildEnvironmentException):
24-
2523
GENERIC_WITH_BUILD_ID = ugettext_noop(
2624
'There was a problem with Read the Docs while building your documentation. '
2725
'Please try again later. '
@@ -31,32 +29,33 @@ class BuildEnvironmentError(BuildEnvironmentException):
3129

3230

3331
class BuildEnvironmentCreationFailed(BuildEnvironmentError):
34-
3532
message = ugettext_noop('Build environment creation failed')
3633

3734

3835
class VersionLockedError(BuildEnvironmentError):
39-
4036
message = ugettext_noop('Version locked, retrying in 5 minutes.')
4137
status_code = 423
4238

4339

4440
class ProjectBuildsSkippedError(BuildEnvironmentError):
45-
4641
message = ugettext_noop('Builds for this project are temporarily disabled')
4742

4843

4944
class YAMLParseError(BuildEnvironmentError):
50-
5145
GENERIC_WITH_PARSE_EXCEPTION = ugettext_noop(
5246
'Problem parsing YAML configuration. {exception}',
5347
)
5448

5549

5650
class BuildTimeoutError(BuildEnvironmentError):
57-
5851
message = ugettext_noop('Build exited due to time out')
5952

6053

6154
class BuildEnvironmentWarning(BuildEnvironmentException):
6255
pass
56+
57+
58+
class MkDocsYAMLParseError(BuildEnvironmentError):
59+
GENERIC_WITH_PARSE_EXCEPTION = ugettext_noop(
60+
'Problem parsing MkDocs YAML configuration. {exception}',
61+
)

0 commit comments

Comments
 (0)