Return null instead of throwing an exception on error 401.
This commit is contained in:
parent
d02394f8de
commit
6a93d31375
2 changed files with 6 additions and 3 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.2.0
|
0.2.1
|
||||||
|
|
|
@ -31,10 +31,13 @@ class V1Client {
|
||||||
*
|
*
|
||||||
* @todo Currently there's no format for apps on the server side.
|
* @todo Currently there's no format for apps on the server side.
|
||||||
* @throws RuntimeException If there is no authenticated entity.
|
* @throws RuntimeException If there is no authenticated entity.
|
||||||
* @return V1User
|
* @return ?V1User
|
||||||
*/
|
*/
|
||||||
public function me(): V1User {
|
public function me(): ?V1User {
|
||||||
$response = $this->httpClient->request('GET', $this->urls->getApiUrl('/v1/me'));
|
$response = $this->httpClient->request('GET', $this->urls->getApiUrl('/v1/me'));
|
||||||
|
if($response->getStatusCode() === 401)
|
||||||
|
return null;
|
||||||
|
|
||||||
$response->ensureSuccessStatusCode();
|
$response->ensureSuccessStatusCode();
|
||||||
|
|
||||||
$me = $response->getJsonBody();
|
$me = $response->getJsonBody();
|
||||||
|
|
Loading…
Reference in a new issue