Commit d2edfc737d210256013bfe001524743e8d3d1060

Authored by Isaac Lewis
1 parent 514a4584

handle logon errors

Showing 1 changed file with 6 additions and 0 deletions   Show diff stats
lib/syspro/logon.rb
@@ -10,6 +10,7 @@ module Syspro @@ -10,6 +10,7 @@ module Syspro
10 'CompanyPassword' => company_password 10 'CompanyPassword' => company_password
11 } 11 }
12 resp = request(:get, resource_url, params) 12 resp = request(:get, resource_url, params)
  13 + handle_errors(resp)
13 UserIdObject.new(resp[0].http_body) 14 UserIdObject.new(resp[0].http_body)
14 end 15 end
15 16
@@ -17,6 +18,11 @@ module Syspro @@ -17,6 +18,11 @@ module Syspro
17 '/Logon' 18 '/Logon'
18 end 19 end
19 20
  21 + def handle_errors(resp)
  22 + body = resp[0].http_body
  23 + raise AuthenticationError, body if body =~ /^(ERROR)/
  24 + end
  25 +
20 UserIdObject = Struct.new(:guid) 26 UserIdObject = Struct.new(:guid)
21 end 27 end
22 end 28 end