Skip to content

Commit

Permalink
Merge pull request #5509 from dojutsu-user/fix-exceptions
Browse files Browse the repository at this point in the history
Use ValueError instead of InvalidParamsException
  • Loading branch information
humitos authored Mar 21, 2019
2 parents 3156083 + 8768d6b commit bb8b08f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions readthedocs/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from readthedocs.builds.constants import BUILD_STATE_TRIGGERED
from readthedocs.doc_builder.constants import DOCKER_LIMITS
from readthedocs.projects.exceptions import InvalidParamsException

log = logging.getLogger(__name__)

Expand All @@ -35,7 +34,7 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable=
after all of the broadcast tasks have finished running.
"""
if type not in ['web', 'app', 'build']:
raise InvalidParamsException('allowed value of `type` are web, app and build.')
raise ValueError('allowed value of `type` are web, app and build.')
if kwargs is None:
kwargs = {}
default_queue = getattr(settings, 'CELERY_DEFAULT_QUEUE', 'celery')
Expand Down
7 changes: 0 additions & 7 deletions readthedocs/projects/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,3 @@ class ProjectSpamError(Exception):
This error is not raised to users, we use this for banning users in the
background.
"""


class InvalidParamsException(Exception):

"""Error raised when incorrect parameters are passed to a function/class."""

pass
4 changes: 2 additions & 2 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from readthedocs.worker import app

from .constants import LOG_TEMPLATE
from .exceptions import ProjectConfigurationError, RepositoryError, InvalidParamsException
from .exceptions import ProjectConfigurationError, RepositoryError
from .models import Domain, HTMLFile, ImportedFile, Project
from .signals import (
after_build,
Expand Down Expand Up @@ -102,7 +102,7 @@ def get_version(project=None, version_pk=None):
:rtype: builds.models.APIVersion
"""
if not (project or version_pk):
raise InvalidParamsException('project or version_pk is needed')
raise ValueError('project or version_pk is needed')
if version_pk:
version_data = api_v2.version(version_pk).get()
else:
Expand Down
5 changes: 2 additions & 3 deletions readthedocs/search/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django_elasticsearch_dsl.registries import registry

from readthedocs.worker import app
from readthedocs.projects.exceptions import InvalidParamsException
from .utils import _get_index, _get_document

log = logging.getLogger(__name__)
Expand All @@ -16,10 +15,10 @@ def index_objects_to_es(
):

if chunk and objects_id:
raise InvalidParamsException('You can not pass both chunk and objects_id.')
raise ValueError('You can not pass both chunk and objects_id.')

if not (chunk or objects_id):
raise InvalidParamsException('You must pass a chunk or objects_id.')
raise ValueError('You must pass a chunk or objects_id.')

model = apps.get_model(app_label, model_name)
document = _get_document(model=model, document_class=document_class)
Expand Down

0 comments on commit bb8b08f

Please sign in to comment.