api: Use custom exceptions in API client.
This removes the use of RuntimeError, and replaces it with a custom error class called ZulipError. In a few places, we use a subclass to make it easier for code to interact with the error type.
This commit is contained in:
parent
b7b083f094
commit
fc1d134685
2 changed files with 24 additions and 18 deletions
|
@ -7,7 +7,7 @@ import unittest
|
|||
import zulip
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from zulip import ZulipError
|
||||
if six.PY2:
|
||||
from mock import patch
|
||||
else:
|
||||
|
@ -38,7 +38,7 @@ Zulip API configuration:
|
|||
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
|
||||
test_path = '~/zuliprc'
|
||||
args = parser.parse_args(['--config-file', test_path])
|
||||
with self.assertRaises(RuntimeError) as cm:
|
||||
with self.assertRaises(ZulipError) as cm:
|
||||
zulip.init_from_options(args)
|
||||
expanded_test_path = os.path.abspath(os.path.expanduser(test_path))
|
||||
self.assertEqual(str(cm.exception), 'api_key or email not specified and '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue