From 3d8c80976a1e0d2d2e8d8776d4e434062f8b0d8b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 14 Jun 2019 08:09:37 +0200 Subject: [PATCH] Use onError for other functions --- lib/src/Client.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/src/Client.dart b/lib/src/Client.dart index 5cdc7fa..3b85da4 100644 --- a/lib/src/Client.dart +++ b/lib/src/Client.dart @@ -183,7 +183,7 @@ class Client { Future logout() async { final dynamic resp = await connection.jsonRequest( type: "POST", action: "/client/r0/logout/all"); - if (resp == null) return; + if (resp is ErrorResponse) connection.onError.add(resp); await connection.clear(); } @@ -194,11 +194,16 @@ class Client { List inviteIDs = []; for (int i = 0; i < users.length; i++) inviteIDs.add(users[i].id); - Map resp = await connection.jsonRequest( + final dynamic resp = await connection.jsonRequest( type: "POST", action: "/client/r0/createRoom", data: {"invite": inviteIDs, "preset": "private_chat"}); + if (resp is ErrorResponse) { + connection.onError.add(resp); + return null; + } + return resp["room_id"]; } }