14
14
from zulipterminal .config .keys import keys_for_command
15
15
from zulipterminal .helper import (
16
16
Message , asynch , canonicalize_color , classify_unread_counts ,
17
- index_messages , initial_index , notify , set_count ,
17
+ index_messages , initial_index , notify , display_error_if_present , set_count ,
18
18
)
19
19
from zulipterminal .ui_tools .utils import create_msg_box_list
20
20
@@ -227,6 +227,7 @@ def _notify_server_of_presence(self) -> Dict[str, Any]:
227
227
}
228
228
)
229
229
self .new_user_input = False
230
+ display_error_if_present (response , self .controller )
230
231
return response
231
232
232
233
@asynch
@@ -269,6 +270,7 @@ def react_to_message(self,
269
270
response = self .client .remove_reaction (reaction_to_toggle_spec )
270
271
else :
271
272
response = self .client .add_reaction (reaction_to_toggle_spec )
273
+ display_error_if_present (response , self .controller )
272
274
273
275
@asynch
274
276
def toggle_message_star_status (self , message : Message ) -> None :
@@ -283,11 +285,12 @@ def toggle_message_star_status(self, message: Message) -> None:
283
285
def mark_message_ids_as_read (self , id_list : List [int ]) -> None :
284
286
if not id_list :
285
287
return
286
- self .client .update_message_flags ({
288
+ response = self .client .update_message_flags ({
287
289
'messages' : id_list ,
288
290
'flag' : 'read' ,
289
291
'op' : 'add' ,
290
292
})
293
+ display_error_if_present (response , self .controller )
291
294
292
295
def send_private_message (self , recipients : str ,
293
296
content : str ) -> bool :
@@ -297,6 +300,7 @@ def send_private_message(self, recipients: str,
297
300
'content' : content ,
298
301
}
299
302
response = self .client .send_message (request )
303
+ display_error_if_present (response , self .controller )
300
304
return response ['result' ] == 'success'
301
305
302
306
def send_stream_message (self , stream : str , topic : str ,
@@ -308,6 +312,7 @@ def send_stream_message(self, stream: str, topic: str,
308
312
'content' : content ,
309
313
}
310
314
response = self .client .send_message (request )
315
+ display_error_if_present (response , self .controller )
311
316
return response ['result' ] == 'success'
312
317
313
318
def update_private_message (self , msg_id : int , content : str ) -> bool :
@@ -316,6 +321,7 @@ def update_private_message(self, msg_id: int, content: str) -> bool:
316
321
"content" : content ,
317
322
}
318
323
response = self .client .update_message (request )
324
+ display_error_if_present (response , self .controller )
319
325
return response ['result' ] == 'success'
320
326
321
327
def update_stream_message (self , topic : str , msg_id : int ,
@@ -328,6 +334,7 @@ def update_stream_message(self, topic: str, msg_id: int,
328
334
"subject" : topic ,
329
335
}
330
336
response = self .client .update_message (request )
337
+ display_error_if_present (response , self .controller )
331
338
return response ['result' ] == 'success'
332
339
333
340
def get_messages (self , * ,
@@ -359,6 +366,7 @@ def get_messages(self, *,
359
366
query_range = num_after + num_before + 1
360
367
self .found_newest = len (response ['messages' ]) < query_range
361
368
return ""
369
+ display_error_if_present (response , self .controller )
362
370
return response ['msg' ]
363
371
364
372
def get_topics_in_stream (self , stream_list : Iterable [int ]) -> str :
@@ -373,6 +381,7 @@ def get_topics_in_stream(self, stream_list: Iterable[int]) -> str:
373
381
self .index ['topics' ][stream_id ] = [topic ['name' ] for
374
382
topic in response ['topics' ]]
375
383
else :
384
+ display_error_if_present (response , self .controller )
376
385
return response ['msg' ]
377
386
return ""
378
387
@@ -609,6 +618,7 @@ def toggle_stream_muted_status(self, stream_id: int) -> bool:
609
618
# True for muting and False for unmuting.
610
619
}]
611
620
response = self .client .update_subscription_settings (request )
621
+ display_error_if_present (response , self .controller )
612
622
return response ['result' ] == 'success'
613
623
614
624
def _handle_subscription_event (self , event : Event ) -> None :
@@ -962,6 +972,7 @@ def _register_desired_events(self, *, fetch_data: bool=False) -> str:
962
972
self .queue_id = response ['queue_id' ]
963
973
self .last_event_id = response ['last_event_id' ]
964
974
return ""
975
+ display_error_if_present (response , self .controller )
965
976
return response ['msg' ]
966
977
967
978
@asynch
0 commit comments