Skip to content

Commit beaee86

Browse files
committed
Use different exception type
1 parent 5ab4bbf commit beaee86

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

kafka/msk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import string
66

7+
from kafka.errors import IllegalArgumentError
78
from kafka.vendor.six.moves import urllib
89

910

@@ -67,7 +68,7 @@ def region(self):
6768
return region
6869

6970
# Otherwise give up
70-
raise Exception('Could not determine region from broker host(s) or aws configuration')
71+
raise IllegalArgumentError('Could not determine region from broker host(s) or aws configuration')
7172

7273
@property
7374
def _credential(self):

test/test_msk.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66
from unittest import TestCase
77

8+
from kafka.errors import IllegalArgumentError
89
from kafka.msk import AwsMskIamClient
910

1011
try:
@@ -81,13 +82,13 @@ def test_aws_msk_iam_no_region(boto_session):
8182
# No region from config
8283
boto_session.get_config_variable = mock.MagicMock(return_value=None)
8384

84-
with TestCase().assertRaises(Exception) as e:
85+
with TestCase().assertRaises(IllegalArgumentError) as e:
8586
# No region from hostname
8687
msk_client = AwsMskIamClient(
8788
host='localhost',
8889
boto_session = boto_session,
8990
)
90-
assert 'Could not determine region from broker host(s) or aws configuration' == str(e.exception)
91+
assert 'IllegalArgumentError: Could not determine region from broker host(s) or aws configuration' == str(e.exception)
9192

9293

9394
@pytest.mark.parametrize('session_token', [(None), ('the_token')])

0 commit comments

Comments
 (0)