diff options
-rw-r--r-- | lib/Matrix/Client/Room.pm6 | 8 | ||||
-rw-r--r-- | t/30-room.t | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/Matrix/Client/Room.pm6 b/lib/Matrix/Client/Room.pm6 index d8a9848..fa4501a 100644 --- a/lib/Matrix/Client/Room.pm6 +++ b/lib/Matrix/Client/Room.pm6 @@ -13,6 +13,14 @@ submethod TWEAK { } method !get-name() { + CATCH { + when X::Matrix::Response { + .code ~~ /M_NOT_FOUND/ + ?? ($!name = '') + !! fail + } + default { fail } + } my $data = $.state('m.room.name'); $!name = $data<name>; } diff --git a/t/30-room.t b/t/30-room.t index e12a17c..56321a0 100644 --- a/t/30-room.t +++ b/t/30-room.t @@ -80,15 +80,11 @@ subtest 'name' => { my $name = "Name room test"; my $test-room = $client.create-room: - :creation_content({ - "m.federate" => False - }); + :creation_content({ + "m.federate" => False + }); - throws-like { - $test-room.name() - }, X::Matrix::Response, - message => /M_NOT_FOUND/, - '.name without name gives event not found'; + is $test-room.name(), ''; lives-ok { $test-room.send-state('m.room.name', :name($name)) |