Skip to content

Commit bd7ba7f

Browse files
author
Marcos Kintschner
authored
Merge pull request #43 from mconf/feature-friendlier-errors
ELOSP-441 Added keys to every BigBlueButtonException
2 parents a57aa3f + 20b9602 commit bd7ba7f

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
@@ -732,10 +732,14 @@ def send_request(url, data=nil)
732732
puts "BigBlueButtonAPI: URL response = #{response.body}" if @debug
733733

734734
rescue Timeout::Error => error
735-
raise BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\". Error: #{error}")
735+
exception = BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\". Error: #{error}")
736+
exception.key = 'TimeoutError'
737+
raise exception
736738

737739
rescue Exception => error
738-
raise BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\". Error: #{error}")
740+
exception = BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\". Error: #{error}")
741+
exception.key = 'IncorrectUrlError'
742+
raise exception
739743
end
740744

741745
response
@@ -751,7 +755,9 @@ def nearest_version(target)
751755

752756
# we don't allow older versions than the one supported, use an old version of the gem for that
753757
if Gem::Version.new(version) < Gem::Version.new(@supported_versions[0])
754-
raise BigBlueButtonException.new("BigBlueButton error: Invalid API version #{version}. Supported versions: #{@supported_versions.join(', ')}")
758+
exception = BigBlueButtonException.new("BigBlueButton error: Invalid API version #{version}. Supported versions: #{@supported_versions.join(', ')}")
759+
exception.key = 'APIVersionError'
760+
raise exception
755761

756762
# allow newer versions by using the newest one we support
757763
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)