Sha256: 48c1e3881428ea2d11e5402717b377382cebd5252f9c89ffd30931b948431329
Contents?: true
Size: 776 Bytes
Versions: 6
Compression:
Stored size: 776 Bytes
Contents
# lib/errors.rb module StreamChat class StreamAPIException < StandardError def initialize(response) @response = response p response begin parsed_response = JSON.parse(response.body) @json_response = true @error_code = parsed_response.fetch("data", {}) .fetch("code", "unknown") @error_message = parsed_response.fetch("data", {}) .fetch("message", "unknown") rescue JSON::ParserError @json_response = false end end def message if @json_response "StreamChat error code #{@error_code}: #{@error_message}" else "StreamChat error HTTP code: #{@response.status}" end end end class StreamChannelException < StandardError; end end
Version data entries
6 entries across 6 versions & 1 rubygems