summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Broker.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Broker.php b/src/Broker.php
index 3daf3ed..1da965e 100644
--- a/src/Broker.php
+++ b/src/Broker.php
@@ -209,7 +209,14 @@ class Broker
list($contentType) = explode(';', curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
if ($contentType != 'application/json') {
- $message = 'Expected application/json response, got ' . $contentType;
+ $pageUrl = preg_replace('/\?.*$/', '', $url);
+ $message = "HTTP request '$method $pageUrl' failed: "
+ . "Expected a application/json response, got $contentType";
+
+ if ($contentType === 'text/html' && preg_match('<title[^>]+>([^<>]+)</title>', $response, $match)) {
+ $message .= " With"
+ }
+
throw new Exception($message);
}