bots: Raise KeyError inside storage.get().
Our bots rely on get() raising `KeyError` if
a key does not exist.
This was a regression in this commit:
MODIFY
zulip_bots/zulip_bots/bots/incident/incident.py
zulip_bots/zulip_bots/bots/incident/incident.py
@@ -2,7 +2,7 @@ import html
import json
import random
import re
-from zulip_bots.lib import Any, StateHandlerError
+from zulip_bots.lib import Any
from typing import Optional, Any, Dict, Tuple
@@ -79,7 +79,7 @@ def parse_answer(query: str) -> Tuple[str, str]:
def generate_ticket_id(storage: Any) -> str:
try:
incident_num = storage.get('ticket_id')
- except (StateHandlerError, KeyError):
+ except (KeyError):
incident_num = 0
incident_num += 1
incident_num = incident_num % (1000)

MODIFY
zulip_bots/zulip_bots/lib.py
zulip_bots/zulip_bots/lib.py
@@ -72,7 +72,7 @@ class StateHandler(object):
response = self._client.get_storage({'keys': [key]})
if response['result'] != 'success':
- raise StateHandlerError("Error fetching state: {}".format(str(response)))
+ raise KeyError('key not found: ' + key)
marshalled_value = response['storage'][key]
self.state_[key] = marshalled_value

bots: Raise KeyError inside storage.get().

Our bots rely on get() raising `KeyError` if
a key does not exist.

This was a regression in this commit:

https://github.com/zulip/python-zulip-api/commit/d7d2f6bbd6e25f4247fb13ff0c113b05c4197ea8