Commit 7d46a01e6994deeed94dc358fce960bfe419e2fb

Authored by Isaac Lewis
1 parent 0e38c117

handle errors refactor

lib/syspro/api_resource.rb
... ... @@ -18,6 +18,12 @@ module Syspro
18 18 "/#{CGI.escape(class_name.downcase)}"
19 19 end
20 20  
  21 + def handle_errors(resp)
  22 + body = resp[0].http_body
  23 + raise AuthenticationError, body if body =~ /^(ERROR: The supplied UserID is invalid.)/
  24 + raise SysproError, body if body =~ /^(ERROR)/
  25 + end
  26 +
21 27 def refresh
22 28 resp, opts = request(:get, resource_url, @retrieve_params)
23 29 initialize_from(resp.data, opts)
... ...
lib/syspro/business_objects/combrw.rb
... ... @@ -34,11 +34,6 @@ module Syspro
34 34 parser = ComBrwParser.new(resp[0].data)
35 35 parser.parse
36 36 end
37   -
38   - def handle_errors(resp)
39   - body = resp[0].http_body
40   - raise SysproError, body if body =~ /^(ERROR)/
41   - end
42 37 end
43 38 end
44 39 end
... ...
lib/syspro/business_objects/comfch.rb
... ... @@ -34,11 +34,6 @@ module Syspro
34 34 parser = ComFchParser.new(resp[0].data)
35 35 parser.parse
36 36 end
37   -
38   - def handle_errors(resp)
39   - body = resp[0].http_body
40   - raise SysproError, body if body =~ /^(ERROR)/
41   - end
42 37 end
43 38 end
44 39 end
... ...
lib/syspro/business_objects/comfnd.rb
... ... @@ -29,11 +29,6 @@ module Syspro
29 29 parser = ComFndParser.new(resp[0].data)
30 30 parser.parse
31 31 end
32   -
33   - def handle_errors(resp)
34   - body = resp[0].http_body
35   - raise SysproError, body if body =~ /^(ERROR)/
36   - end
37 32 end
38 33 end
39 34 end
... ...
lib/syspro/business_objects/porqry.rb
... ... @@ -37,11 +37,6 @@ module Syspro
37 37 parser = PorQryParser.new(resp[0].data)
38 38 parser.parse
39 39 end
40   -
41   - def handle_errors(resp)
42   - body = resp[0].http_body
43   - raise SysproError, body if body =~ /^(ERROR)/
44   - end
45 40 end
46 41 end
47 42 end
... ...
lib/syspro/business_objects/portor.rb
... ... @@ -40,11 +40,6 @@ module Syspro
40 40 parser = PorTorParser.new(resp[0].data)
41 41 parser.parse
42 42 end
43   -
44   - def handle_errors(resp)
45   - body = resp[0].http_body
46   - raise SysproError, body if body =~ /^(ERROR)/
47   - end
48 43 end
49 44 end
50 45 end
... ...
lib/syspro/business_objects/sorqry.rb
... ... @@ -31,11 +31,6 @@ module Syspro
31 31 parser = SorQryParser.new(resp[0].data)
32 32 parser.parse
33 33 end
34   -
35   - def handle_errors(resp)
36   - body = resp[0].http_body
37   - raise SysproError, body if body =~ /^(ERROR)/
38   - end
39 34 end
40 35 end
41 36 end
... ...