@@ -21,11 +21,6 @@ def __init__(self, team: str) -> None:
21
21
self .team = team
22
22
23
23
24
- class UnknownCommandSyntaxError (Exception ):
25
- def __init__ (self , detail : str ) -> None :
26
- self .detail = detail
27
-
28
-
29
24
class UnspecifiedProblemError (Exception ):
30
25
pass
31
26
@@ -114,6 +109,13 @@ def entries_list(team_name: str) -> str:
114
109
return response
115
110
116
111
112
+ def unknown_command_reply (detail : str ) -> str :
113
+ return (
114
+ "Sorry, I don't understand what your trying to say. Use `@mention help` to see my help. "
115
+ + detail
116
+ )
117
+
118
+
117
119
def create_entry (message : str ) -> str :
118
120
single_word_regex = re .compile ("--team=([a-zA-Z0-9_]*)" )
119
121
multiword_regex = re .compile ('"--team=([^"]*)"' )
@@ -133,7 +135,7 @@ def create_entry(message: str) -> str:
133
135
team = default_team
134
136
new_message = message
135
137
else :
136
- raise UnknownCommandSyntaxError (
138
+ return unknown_command_reply (
137
139
"""I don't know which team you meant for me to create an entry under.
138
140
Either set a default team or pass the `--team` flag.
139
141
More information in my help"""
@@ -219,7 +221,7 @@ def get_response(self, message: Dict[str, Any]) -> str:
219
221
if len (message_content ) > 2 :
220
222
reply = team_info (" " .join (message_content [2 :]))
221
223
else :
222
- raise UnknownCommandSyntaxError (
224
+ reply = unknown_command_reply (
223
225
"You must specify the team in which you request information from."
224
226
)
225
227
elif command in ["entries list" , "list entries" ]:
@@ -229,7 +231,7 @@ def get_response(self, message: Dict[str, Any]) -> str:
229
231
elif command in ["help" ]:
230
232
reply = self .usage ()
231
233
else :
232
- raise UnknownCommandSyntaxError (
234
+ reply = unknown_command_reply (
233
235
"I can't understand the command you sent me :confused: "
234
236
)
235
237
except TeamNotFoundError as e :
@@ -239,11 +241,6 @@ def get_response(self, message: Dict[str, Any]) -> str:
239
241
except AuthenticationError :
240
242
reply = "I can't currently authenticate with idonethis. "
241
243
reply += "Can you check that your API key is correct? For more information see my documentation."
242
- except UnknownCommandSyntaxError as e :
243
- reply = (
244
- "Sorry, I don't understand what your trying to say. Use `@mention help` to see my help. "
245
- + e .detail
246
- )
247
244
except Exception : # catches UnspecifiedProblemException, and other problems
248
245
reply = "Oh dear, I'm having problems processing your request right now. Perhaps you could try again later :grinning:"
249
246
logging .exception ("Exception caught" )
0 commit comments