Improve error handling for Xero linking
This commit is contained in:
parent
26b14246e1
commit
ec4fcd3fc8
2 changed files with 9 additions and 4 deletions
|
@ -356,9 +356,13 @@ getTenantId pipe dbName t = do
|
||||||
setRequestMethod "GET" defaultRequest
|
setRequestMethod "GET" defaultRequest
|
||||||
res <- httpJSON req
|
res <- httpJSON req
|
||||||
let tenants = getResponseBody (res :: Response [XeroTenant])
|
let tenants = getResponseBody (res :: Response [XeroTenant])
|
||||||
--print tenants
|
print tenants
|
||||||
_ <- access pipe master dbName $ setTenant (t_address t) (head tenants)
|
if not (null tenants)
|
||||||
|
then do
|
||||||
|
_ <-
|
||||||
|
access pipe master dbName $ setTenant (t_address t) (head tenants)
|
||||||
return ()
|
return ()
|
||||||
|
else error "Couldn't find tenant ID"
|
||||||
_ -> error "Incorrect type for authorization_event_id"
|
_ -> error "Incorrect type for authorization_event_id"
|
||||||
|
|
||||||
-- | Update an Owner with XeroTenant id
|
-- | Update an Owner with XeroTenant id
|
||||||
|
|
|
@ -548,7 +548,8 @@ routes pipe config = do
|
||||||
Nothing -> status noContent204
|
Nothing -> status noContent204
|
||||||
Just c -> do
|
Just c -> do
|
||||||
res <-
|
res <-
|
||||||
liftIO $ requestXeroToken pipe (c_dbName config) c code address
|
liftAndCatchIO $
|
||||||
|
requestXeroToken pipe (c_dbName config) c code address
|
||||||
if res
|
if res
|
||||||
then status ok200
|
then status ok200
|
||||||
else status noContent204
|
else status noContent204
|
||||||
|
|
Loading…
Reference in a new issue