[Event] Add trycatch block
This commit is contained in:
parent
6117606b28
commit
5df56ea12f
|
@ -66,8 +66,12 @@ class RawEvent {
|
||||||
this.room});
|
this.room});
|
||||||
|
|
||||||
static Map<String, dynamic> getMapFromPayload(dynamic payload) {
|
static Map<String, dynamic> getMapFromPayload(dynamic payload) {
|
||||||
if (payload == null || payload == "") return {};
|
if (payload is String)
|
||||||
if (payload is String) return json.decode(payload);
|
try {
|
||||||
|
return json.decode(payload);
|
||||||
|
} catch (e) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
if (payload is Map<String, dynamic>) return payload;
|
if (payload is Map<String, dynamic>) return payload;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue