Skip to content

Commit 2a2e18f

Browse files
Merge pull request #6 from BitbucketAPI/detail
Present the error detail if possible too
2 parents 7d45af0 + 9e2881d commit 2a2e18f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/HttpClient/Plugin/ExceptionThrower.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ private static function handleError(int $status, string $message = null)
9696
private static function getMessage(ResponseInterface $response)
9797
{
9898
try {
99-
return ResponseMediator::getContent($response)['error']['message'] ?? null;
99+
if ($error = ResponseMediator::getContent($response)['error'] ?? null) {
100+
if ($message = $error['message'] ?? null) {
101+
if ($detail = $error['detail'] ?? null) {
102+
return sprintf('%s: %s', $message, strtok($detail, "\n"));
103+
} else {
104+
return $message;
105+
}
106+
}
107+
}
100108
} catch (DecodingFailedException $e) {
101109
// return nothing
102110
}

0 commit comments

Comments
 (0)