Skip to content
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
6 changes: 5 additions & 1 deletion ravendb/exceptions/cluster.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from ravendb.exceptions.raven_exceptions import RavenException


class NoLoaderException(RavenException):
class NoLeaderException(RavenException):
pass


# The name this class shipped under.
NoLoaderException = NoLeaderException


class NodeIsPassiveException(RavenException):
pass
4 changes: 2 additions & 2 deletions ravendb/exceptions/exception_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from datetime import timedelta

from ravendb.exceptions.cluster import NodeIsPassiveException, NoLoaderException
from ravendb.exceptions.cluster import NodeIsPassiveException, NoLeaderException
from ravendb.exceptions.commercial import LicenseLimitException
from ravendb.exceptions.documents import DocumentConflictException, DocumentDoesNotExistException
from ravendb.exceptions.documents.bulkinsert import BulkInsertAbortedException, BulkInsertProtocolViolationException
Expand Down Expand Up @@ -62,7 +62,7 @@
"ReplicationHubNotFoundException": ReplicationHubNotFoundException,
# cluster
"NodeIsPassiveException": NodeIsPassiveException,
"NoLoaderException": NoLoaderException,
"NoLeaderException": NoLeaderException,
# commercial
"LicenseLimitException": LicenseLimitException,
}
Expand Down
34 changes: 34 additions & 0 deletions ravendb/tests/issue_tests/test_exception_dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import http
from unittest import TestCase

from ravendb.exceptions.cluster import NoLeaderException, NoLoaderException
from ravendb.exceptions.exception_dispatcher import ExceptionDispatcher
from ravendb.exceptions.raven_exceptions import RavenException


def _dispatch(type_as_string: str) -> RavenException:
schema = ExceptionDispatcher.ExceptionSchema(
url="http://localhost:8080",
object_type=type_as_string,
message="no leader",
error="no leader",
)
schema.type = type_as_string
return ExceptionDispatcher.get(schema, http.HTTPStatus.INTERNAL_SERVER_ERROR)


class TestExceptionDispatcher(TestCase):
def test_no_leader_from_the_server_is_typed(self):
# The map was keyed on "NoLoaderException", which the server never sends, so a real
# no-leader failure arrived as a plain RavenException.
exception = _dispatch("Raven.Client.Exceptions.Cluster.NoLeaderException")

self.assertIsInstance(exception, NoLeaderException)

def test_the_old_misspelled_name_is_still_importable(self):
self.assertIs(NoLeaderException, NoLoaderException)

def test_an_unknown_type_stays_a_raven_exception(self):
exception = _dispatch("Raven.Client.Exceptions.Cluster.SomethingElseException")

self.assertIs(RavenException, type(exception))
Loading