From ccbe440da4d9708a0c19d52967709171e08317a1 Mon Sep 17 00:00:00 2001 From: reachire-smendola <56935044+reachire-smendola@users.noreply.github.com> Date: Thu, 21 Oct 2021 14:13:38 -0400 Subject: [PATCH] Access error details through StreamAPIException class attr_readers (#56) * add accessors and to_s to StreamAPIException class * remove resonse attr reader, and add json_response? --- lib/stream-chat/errors.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/stream-chat/errors.rb b/lib/stream-chat/errors.rb index 4ce5cf8..5dfebf8 100644 --- a/lib/stream-chat/errors.rb +++ b/lib/stream-chat/errors.rb @@ -4,6 +4,9 @@ module StreamChat class StreamAPIException < StandardError + attr_reader :error_code + attr_reader :error_message + def initialize(response) super() @response = response @@ -24,6 +27,14 @@ def message "StreamChat error HTTP code: #{@response.status}" end end + + def json_response? + @json_response + end + + def to_s + message + end end class StreamChannelException < StandardError; end