Return null instead of throwing an exception on error 401.

This commit is contained in:
Pachira 2024-11-16 16:03:42 +00:00
parent d02394f8de
commit 6a93d31375
2 changed files with 6 additions and 3 deletions

View file

@ -1 +1 @@
0.2.0
0.2.1

View file

@ -31,10 +31,13 @@ class V1Client {
*
* @todo Currently there's no format for apps on the server side.
* @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'));
if($response->getStatusCode() === 401)
return null;
$response->ensureSuccessStatusCode();
$me = $response->getJsonBody();