Commit 0cbc9681bef893f5c215b8977c4ab6d0268aa7e4
1 parent
49468ce4
Exists in
master
and in
1 other branch
Added more info to ApiVersionError, and parsed['version'] should be tested as a string.
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
lib/hoptoad.rb
| @@ -3,14 +3,14 @@ module Hoptoad | @@ -3,14 +3,14 @@ module Hoptoad | ||
| 3 | require 'digest/md5' | 3 | require 'digest/md5' |
| 4 | 4 | ||
| 5 | class ApiVersionError < StandardError | 5 | class ApiVersionError < StandardError |
| 6 | - def initialize | ||
| 7 | - super "Wrong API Version: Expecting v2.0" | 6 | + def initialize(version) |
| 7 | + super "Wrong API Version: Expecting v2.0, got version: #{version}" | ||
| 8 | end | 8 | end |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | def self.parse_xml(xml) | 11 | def self.parse_xml(xml) |
| 12 | parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice'] | 12 | parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice'] |
| 13 | - raise ApiVersionError unless parsed && parsed['version'] == '2.0' | 13 | + raise ApiVersionError(parsed['version']) unless parsed && parsed['version'].to_s == '2.0' |
| 14 | rekeyed = rekey(parsed) | 14 | rekeyed = rekey(parsed) |
| 15 | rekeyed['fingerprint'] = Digest::MD5.hexdigest(rekeyed['error']['backtrace'].to_s) | 15 | rekeyed['fingerprint'] = Digest::MD5.hexdigest(rekeyed['error']['backtrace'].to_s) |
| 16 | rekeyed | 16 | rekeyed |
| @@ -43,3 +43,4 @@ module Hoptoad | @@ -43,3 +43,4 @@ module Hoptoad | ||
| 43 | end | 43 | end |
| 44 | end | 44 | end |
| 45 | end | 45 | end |
| 46 | + |