Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ValueError instead of InvalidParamsException #5509

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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