Skip to content

Commit

Permalink
Merge pull request #4814 from invinciblycool/add-exception
Browse files Browse the repository at this point in the history
Add MkDocsYAMLParseError
  • Loading branch information
ericholscher authored Nov 1, 2018
2 parents e35e5ff + 1bcc070 commit bc248aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions readthedocs/doc_builder/backends/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.template import loader as template_loader

from readthedocs.doc_builder.base import BaseBuilder
from readthedocs.doc_builder.exceptions import BuildEnvironmentError
from readthedocs.doc_builder.exceptions import MkDocsYAMLParseError
from readthedocs.projects.models import Feature

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -99,7 +99,7 @@ def load_yaml_config(self):
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
note = ' (line %d, column %d)' % (mark.line + 1, mark.column + 1)
raise BuildEnvironmentError(
raise MkDocsYAMLParseError(
'Your mkdocs.yml could not be loaded, '
'possibly due to a syntax error{note}'.format(note=note)
)
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from .exceptions import (
BuildEnvironmentCreationFailed, BuildEnvironmentError,
BuildEnvironmentException, BuildEnvironmentWarning, BuildTimeoutError,
ProjectBuildsSkippedError, VersionLockedError, YAMLParseError)
ProjectBuildsSkippedError, VersionLockedError, YAMLParseError, MkDocsYAMLParseError)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -438,6 +438,7 @@ class BuildEnvironment(BaseEnvironment):
ProjectBuildsSkippedError,
YAMLParseError,
BuildTimeoutError,
MkDocsYAMLParseError
)

def __init__(self, project=None, version=None, build=None, config=None,
Expand Down
13 changes: 6 additions & 7 deletions readthedocs/doc_builder/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class BuildEnvironmentException(Exception):

message = None
status_code = None

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


class BuildEnvironmentError(BuildEnvironmentException):

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


class BuildEnvironmentCreationFailed(BuildEnvironmentError):

message = ugettext_noop('Build environment creation failed')


class VersionLockedError(BuildEnvironmentError):

message = ugettext_noop('Version locked, retrying in 5 minutes.')
status_code = 423


class ProjectBuildsSkippedError(BuildEnvironmentError):

message = ugettext_noop('Builds for this project are temporarily disabled')


class YAMLParseError(BuildEnvironmentError):

GENERIC_WITH_PARSE_EXCEPTION = ugettext_noop(
'Problem parsing YAML configuration. {exception}',
)


class BuildTimeoutError(BuildEnvironmentError):

message = ugettext_noop('Build exited due to time out')


class BuildEnvironmentWarning(BuildEnvironmentException):
pass


class MkDocsYAMLParseError(BuildEnvironmentError):
GENERIC_WITH_PARSE_EXCEPTION = ugettext_noop(
'Problem parsing MkDocs YAML configuration. {exception}',
)

0 comments on commit bc248aa

Please sign in to comment.