From e2f0ad09daca8de1f5f98e260c4107af0e7f3053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Tue, 18 Sep 2018 08:52:00 +0200 Subject: [PATCH] history: warn on error --- src/rooms.jl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rooms.jl b/src/rooms.jl index 1337c83..0556c77 100644 --- a/src/rooms.jl +++ b/src/rooms.jl @@ -60,7 +60,17 @@ end function history(u::MatrixUser, room_id::String; limit = 15) res = roomhistory(u, room_id, limit = limit) - map(x -> println(MatrixMsg(x["sender"], x["origin_server_ts"], - x["content"]["msgtype"], x["content"]["body"], - )), res["chunk"]) + map(x -> try + println(MatrixMsg(x["sender"], x["origin_server_ts"], + x["content"]["msgtype"], x["content"]["body"], + )) + catch e + if isa(e, KeyError) + @warn "Improve me! Key not found:" + @show x + else + throw(e) + end + end + , res["chunk"]) end