Skip to content

Commit 318c8c7

Browse files
committed
Added keys to every BigBlueButtonException
With these keys we can display a better error flash on the bigbluebutton_rails gem.
1 parent 702c2ca commit 318c8c7

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

lib/bigbluebutton_api.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,14 @@ def send_request(url, data=nil)
760760
puts "BigBlueButtonAPI: URL response = #{response.body}" if @debug
761761

762762
rescue TimeoutError => error
763-
raise BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\". Error: #{error}")
763+
exception = BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\". Error: #{error}")
764+
exception.key = 'TimeoutError'
765+
raise exception
764766

765767
rescue Exception => error
766-
raise BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\". Error: #{error}")
768+
exception = BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\". Error: #{error}")
769+
exception.key = 'IncorrectUrlError'
770+
raise exception
767771
end
768772

769773
response
@@ -779,7 +783,9 @@ def nearest_version(target)
779783

780784
# we don't allow older versions than the one supported, use an old version of the gem for that
781785
if Gem::Version.new(version) < Gem::Version.new(@supported_versions[0])
782-
raise BigBlueButtonException.new("BigBlueButton error: Invalid API version #{version}. Supported versions: #{@supported_versions.join(', ')}")
786+
exception = BigBlueButtonException.new("BigBlueButton error: Invalid API version #{version}. Supported versions: #{@supported_versions.join(', ')}")
787+
exception.key = 'APIVersionError'
788+
raise exception
783789

784790
# allow newer versions by using the newest one we support
785791
elsif Gem::Version.new(version) > Gem::Version.new(@supported_versions.last)

lib/bigbluebutton_config_layout.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def initialize(xml)
2929
begin
3030
@xml = XmlSimple.xml_in(xml, opts)
3131
rescue Exception => e
32-
raise BigBlueButton::BigBlueButtonException.new("Error parsing the layouts XML. Error: #{e.message}")
32+
exception = BigBlueButton::BigBlueButtonException.new("Error parsing the layouts XML. Error: #{e.message}")
33+
exception.key = 'XMLParsingError'
34+
raise exception
3335
end
3436
end
3537

lib/bigbluebutton_config_xml.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def initialize(xml)
3333
@xml = XmlSimple.xml_in(xml, opts)
3434
@original_string = self.as_string.clone
3535
rescue Exception => e
36-
raise BigBlueButton::BigBlueButtonException.new("Error parsing the config XML. Error: #{e.message}")
36+
exception = BigBlueButton::BigBlueButtonException.new("Error parsing the config XML. Error: #{e.message}")
37+
exception.key = 'XMLParsingError'
38+
raise exception
3739
end
3840
end
3941
end

lib/bigbluebutton_hash_to_xml.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def from_xml(xml_io)
1010
hash = XmlSimple.xml_in(xml_io, opts)
1111
return symbolize_keys(hash)
1212
rescue Exception => e
13-
raise BigBlueButtonException.new("Impossible to convert XML to hash. Error: #{e.message}")
13+
exception = BigBlueButtonException.new("Impossible to convert XML to hash. Error: #{e.message}")
14+
exception.key = 'XMLConversionError'
15+
raise exception
1416
end
1517
end
1618

0 commit comments

Comments
 (0)