From 8bfdebe8bf6b527b224bd96d2d134f3b3d5aea96 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Thu, 6 Sep 2018 22:57:24 +1200 Subject: [PATCH] Handle HTTP 400 responses from Vend, decode and throw the details --- src/VendAPI/VendAPI.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/VendAPI/VendAPI.php b/src/VendAPI/VendAPI.php index cf1db24..98423cc 100644 --- a/src/VendAPI/VendAPI.php +++ b/src/VendAPI/VendAPI.php @@ -126,7 +126,7 @@ public function getRegisters($options = array()) return $this->apiGetRegisters($path); } - + /** * Get all sales * @@ -322,6 +322,10 @@ private function _request($path, $data = null, $depage = null) // Check for 400+ error: if($this->requestr->http_code >= 400) { + if($this->requestr->http_code == 400) { + // Error response from Vend, decode it and throw it + throw new Exception($result->error.'. '.$result->details); + } if($this->requestr->http_code == 429) { // Too Many Requests $retry_after = strtotime($result->{'retry-after'}); if($retry_after < time()) {