Skip to content

Commit 7dff8df

Browse files
committed
Adding lastCallFailed method to AbstractApi to tell whether or not the last API call failed.
1 parent 7c74f94 commit 7dff8df

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Redmine/Api/AbstractApi.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public function __construct(Client $client)
2626
$this->client = $client;
2727
}
2828

29+
/**
30+
* Returns whether or not the last api call failed.
31+
*
32+
* @return bool
33+
*/
34+
public function lastCallFailed() {
35+
$clientResponseCode = $this->client->getResponseCode();
36+
return $clientResponseCode < 200 || $clientResponseCode >= 400;
37+
}
38+
2939
/**
3040
* {@inheritDoc}
3141
*/

0 commit comments

Comments
 (0)