Catch exceptions for room events and print out a error message.
This commit is contained in:
parent
31fc14c27f
commit
d97323e7e8
1 changed files with 25 additions and 15 deletions
|
@ -139,11 +139,13 @@ class RoomInfo():
|
||||||
membership_events = []
|
membership_events = []
|
||||||
other_events = []
|
other_events = []
|
||||||
|
|
||||||
|
try:
|
||||||
for event in parsed_dict:
|
for event in parsed_dict:
|
||||||
if event["type"] == "m.room.message":
|
if event["type"] == "m.room.message":
|
||||||
other_events.append(RoomInfo._message_from_event(event))
|
other_events.append(RoomInfo._message_from_event(event))
|
||||||
elif event["type"] == "m.room.member":
|
elif event["type"] == "m.room.member":
|
||||||
membership_events.append(RoomInfo._membership_from_dict(event))
|
membership_events.append(
|
||||||
|
RoomInfo._membership_from_dict(event))
|
||||||
elif event["type"] == "m.room.power_levels":
|
elif event["type"] == "m.room.power_levels":
|
||||||
other_events.append(RoomPowerLevels.from_dict(event))
|
other_events.append(RoomPowerLevels.from_dict(event))
|
||||||
elif event["type"] == "m.room.topic":
|
elif event["type"] == "m.room.topic":
|
||||||
|
@ -154,6 +156,14 @@ class RoomInfo():
|
||||||
other_events.append(RoomNameEvent.from_dict(event))
|
other_events.append(RoomNameEvent.from_dict(event))
|
||||||
elif event["type"] == "m.room.aliases":
|
elif event["type"] == "m.room.aliases":
|
||||||
other_events.append(RoomAliasEvent.from_dict(event))
|
other_events.append(RoomAliasEvent.from_dict(event))
|
||||||
|
except (ValueError, TypeError, KeyError) as error:
|
||||||
|
message = ("{prefix}matrix: Error parsing "
|
||||||
|
"room event of type {type}: {error}").format(
|
||||||
|
prefix=W.prefix("error"),
|
||||||
|
type=event["type"],
|
||||||
|
error=str(error))
|
||||||
|
W.prnt("", message)
|
||||||
|
raise
|
||||||
|
|
||||||
return (membership_events, other_events)
|
return (membership_events, other_events)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue