Skip to content

Commit bb8b08f

Browse files
authored
Merge pull request #5509 from dojutsu-user/fix-exceptions
Use ValueError instead of InvalidParamsException
2 parents 3156083 + 8768d6b commit bb8b08f

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

readthedocs/core/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from readthedocs.builds.constants import BUILD_STATE_TRIGGERED
2020
from readthedocs.doc_builder.constants import DOCKER_LIMITS
21-
from readthedocs.projects.exceptions import InvalidParamsException
2221

2322
log = logging.getLogger(__name__)
2423

@@ -35,7 +34,7 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable=
3534
after all of the broadcast tasks have finished running.
3635
"""
3736
if type not in ['web', 'app', 'build']:
38-
raise InvalidParamsException('allowed value of `type` are web, app and build.')
37+
raise ValueError('allowed value of `type` are web, app and build.')
3938
if kwargs is None:
4039
kwargs = {}
4140
default_queue = getattr(settings, 'CELERY_DEFAULT_QUEUE', 'celery')

readthedocs/projects/exceptions.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,3 @@ class ProjectSpamError(Exception):
6060
This error is not raised to users, we use this for banning users in the
6161
background.
6262
"""
63-
64-
65-
class InvalidParamsException(Exception):
66-
67-
"""Error raised when incorrect parameters are passed to a function/class."""
68-
69-
pass

readthedocs/projects/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
from readthedocs.worker import app
6868

6969
from .constants import LOG_TEMPLATE
70-
from .exceptions import ProjectConfigurationError, RepositoryError, InvalidParamsException
70+
from .exceptions import ProjectConfigurationError, RepositoryError
7171
from .models import Domain, HTMLFile, ImportedFile, Project
7272
from .signals import (
7373
after_build,
@@ -102,7 +102,7 @@ def get_version(project=None, version_pk=None):
102102
:rtype: builds.models.APIVersion
103103
"""
104104
if not (project or version_pk):
105-
raise InvalidParamsException('project or version_pk is needed')
105+
raise ValueError('project or version_pk is needed')
106106
if version_pk:
107107
version_data = api_v2.version(version_pk).get()
108108
else:

readthedocs/search/tasks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django_elasticsearch_dsl.registries import registry
55

66
from readthedocs.worker import app
7-
from readthedocs.projects.exceptions import InvalidParamsException
87
from .utils import _get_index, _get_document
98

109
log = logging.getLogger(__name__)
@@ -16,10 +15,10 @@ def index_objects_to_es(
1615
):
1716

1817
if chunk and objects_id:
19-
raise InvalidParamsException('You can not pass both chunk and objects_id.')
18+
raise ValueError('You can not pass both chunk and objects_id.')
2019

2120
if not (chunk or objects_id):
22-
raise InvalidParamsException('You must pass a chunk or objects_id.')
21+
raise ValueError('You must pass a chunk or objects_id.')
2322

2423
model = apps.get_model(app_label, model_name)
2524
document = _get_document(model=model, document_class=document_class)

0 commit comments

Comments
 (0)