Commit 7d46a01e6994deeed94dc358fce960bfe419e2fb
1 parent
0e38c117
handle errors refactor
Showing
7 changed files
with
6 additions
and
30 deletions
Show diff stats
lib/syspro/api_resource.rb
@@ -18,6 +18,12 @@ module Syspro | @@ -18,6 +18,12 @@ module Syspro | ||
18 | "/#{CGI.escape(class_name.downcase)}" | 18 | "/#{CGI.escape(class_name.downcase)}" |
19 | end | 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 | def refresh | 27 | def refresh |
22 | resp, opts = request(:get, resource_url, @retrieve_params) | 28 | resp, opts = request(:get, resource_url, @retrieve_params) |
23 | initialize_from(resp.data, opts) | 29 | initialize_from(resp.data, opts) |
lib/syspro/business_objects/combrw.rb
@@ -34,11 +34,6 @@ module Syspro | @@ -34,11 +34,6 @@ module Syspro | ||
34 | parser = ComBrwParser.new(resp[0].data) | 34 | parser = ComBrwParser.new(resp[0].data) |
35 | parser.parse | 35 | parser.parse |
36 | end | 36 | end |
37 | - | ||
38 | - def handle_errors(resp) | ||
39 | - body = resp[0].http_body | ||
40 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
41 | - end | ||
42 | end | 37 | end |
43 | end | 38 | end |
44 | end | 39 | end |
lib/syspro/business_objects/comfch.rb
@@ -34,11 +34,6 @@ module Syspro | @@ -34,11 +34,6 @@ module Syspro | ||
34 | parser = ComFchParser.new(resp[0].data) | 34 | parser = ComFchParser.new(resp[0].data) |
35 | parser.parse | 35 | parser.parse |
36 | end | 36 | end |
37 | - | ||
38 | - def handle_errors(resp) | ||
39 | - body = resp[0].http_body | ||
40 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
41 | - end | ||
42 | end | 37 | end |
43 | end | 38 | end |
44 | end | 39 | end |
lib/syspro/business_objects/comfnd.rb
@@ -29,11 +29,6 @@ module Syspro | @@ -29,11 +29,6 @@ module Syspro | ||
29 | parser = ComFndParser.new(resp[0].data) | 29 | parser = ComFndParser.new(resp[0].data) |
30 | parser.parse | 30 | parser.parse |
31 | end | 31 | end |
32 | - | ||
33 | - def handle_errors(resp) | ||
34 | - body = resp[0].http_body | ||
35 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
36 | - end | ||
37 | end | 32 | end |
38 | end | 33 | end |
39 | end | 34 | end |
lib/syspro/business_objects/porqry.rb
@@ -37,11 +37,6 @@ module Syspro | @@ -37,11 +37,6 @@ module Syspro | ||
37 | parser = PorQryParser.new(resp[0].data) | 37 | parser = PorQryParser.new(resp[0].data) |
38 | parser.parse | 38 | parser.parse |
39 | end | 39 | end |
40 | - | ||
41 | - def handle_errors(resp) | ||
42 | - body = resp[0].http_body | ||
43 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
44 | - end | ||
45 | end | 40 | end |
46 | end | 41 | end |
47 | end | 42 | end |
lib/syspro/business_objects/portor.rb
@@ -40,11 +40,6 @@ module Syspro | @@ -40,11 +40,6 @@ module Syspro | ||
40 | parser = PorTorParser.new(resp[0].data) | 40 | parser = PorTorParser.new(resp[0].data) |
41 | parser.parse | 41 | parser.parse |
42 | end | 42 | end |
43 | - | ||
44 | - def handle_errors(resp) | ||
45 | - body = resp[0].http_body | ||
46 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
47 | - end | ||
48 | end | 43 | end |
49 | end | 44 | end |
50 | end | 45 | end |
lib/syspro/business_objects/sorqry.rb
@@ -31,11 +31,6 @@ module Syspro | @@ -31,11 +31,6 @@ module Syspro | ||
31 | parser = SorQryParser.new(resp[0].data) | 31 | parser = SorQryParser.new(resp[0].data) |
32 | parser.parse | 32 | parser.parse |
33 | end | 33 | end |
34 | - | ||
35 | - def handle_errors(resp) | ||
36 | - body = resp[0].http_body | ||
37 | - raise SysproError, body if body =~ /^(ERROR)/ | ||
38 | - end | ||
39 | end | 34 | end |
40 | end | 35 | end |
41 | end | 36 | end |