From 7d46a01e6994deeed94dc358fce960bfe419e2fb Mon Sep 17 00:00:00 2001 From: Isaac Lewis Date: Tue, 5 Jun 2018 15:02:46 -0700 Subject: [PATCH] handle errors refactor --- lib/syspro/api_resource.rb | 6 ++++++ lib/syspro/business_objects/combrw.rb | 5 ----- lib/syspro/business_objects/comfch.rb | 5 ----- lib/syspro/business_objects/comfnd.rb | 5 ----- lib/syspro/business_objects/porqry.rb | 5 ----- lib/syspro/business_objects/portor.rb | 5 ----- lib/syspro/business_objects/sorqry.rb | 5 ----- 7 files changed, 6 insertions(+), 30 deletions(-) diff --git a/lib/syspro/api_resource.rb b/lib/syspro/api_resource.rb index 19a30c5..a84f25a 100644 --- a/lib/syspro/api_resource.rb +++ b/lib/syspro/api_resource.rb @@ -18,6 +18,12 @@ module Syspro "/#{CGI.escape(class_name.downcase)}" end + def handle_errors(resp) + body = resp[0].http_body + raise AuthenticationError, body if body =~ /^(ERROR: The supplied UserID is invalid.)/ + raise SysproError, body if body =~ /^(ERROR)/ + end + def refresh resp, opts = request(:get, resource_url, @retrieve_params) initialize_from(resp.data, opts) diff --git a/lib/syspro/business_objects/combrw.rb b/lib/syspro/business_objects/combrw.rb index 5a8787f..44a0be0 100644 --- a/lib/syspro/business_objects/combrw.rb +++ b/lib/syspro/business_objects/combrw.rb @@ -34,11 +34,6 @@ module Syspro parser = ComBrwParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end diff --git a/lib/syspro/business_objects/comfch.rb b/lib/syspro/business_objects/comfch.rb index 66ce6ea..70fe926 100644 --- a/lib/syspro/business_objects/comfch.rb +++ b/lib/syspro/business_objects/comfch.rb @@ -34,11 +34,6 @@ module Syspro parser = ComFchParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end diff --git a/lib/syspro/business_objects/comfnd.rb b/lib/syspro/business_objects/comfnd.rb index ec5589e..caf221e 100644 --- a/lib/syspro/business_objects/comfnd.rb +++ b/lib/syspro/business_objects/comfnd.rb @@ -29,11 +29,6 @@ module Syspro parser = ComFndParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end diff --git a/lib/syspro/business_objects/porqry.rb b/lib/syspro/business_objects/porqry.rb index 7af4570..01ead07 100644 --- a/lib/syspro/business_objects/porqry.rb +++ b/lib/syspro/business_objects/porqry.rb @@ -37,11 +37,6 @@ module Syspro parser = PorQryParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end diff --git a/lib/syspro/business_objects/portor.rb b/lib/syspro/business_objects/portor.rb index 12f1e0f..05914ab 100644 --- a/lib/syspro/business_objects/portor.rb +++ b/lib/syspro/business_objects/portor.rb @@ -40,11 +40,6 @@ module Syspro parser = PorTorParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end diff --git a/lib/syspro/business_objects/sorqry.rb b/lib/syspro/business_objects/sorqry.rb index 087e86c..976b409 100644 --- a/lib/syspro/business_objects/sorqry.rb +++ b/lib/syspro/business_objects/sorqry.rb @@ -31,11 +31,6 @@ module Syspro parser = SorQryParser.new(resp[0].data) parser.parse end - - def handle_errors(resp) - body = resp[0].http_body - raise SysproError, body if body =~ /^(ERROR)/ - end end end end -- libgit2 0.21.4