Skip to content

Commit e361d11

Browse files
committed
🐛 postal exception codes are not numeric
1 parent aeef3a7 commit e361d11

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/Client.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ protected function validateResponse(ResponseInterface $response): array
7373
$code = 0;
7474
if (isset($json['data']['code'])) {
7575
$message = $json['data']['code'] . ': ' . $message;
76-
$code = $json['data']['code'];
7776
}
7877

79-
throw new ApiException($message, $code);
78+
throw new ApiException($message);
8079
}
8180

8281
if (! isset($json['data'])) {

tests/ClientTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ public function testPrepareResponseThrowsApiErrors(): void
4141
$response = new Response(200, [], json_encode([
4242
'status' => 'error',
4343
'data' => [
44-
'code' => 5,
44+
'code' => 'TestExceptionCode',
4545
'message' => 'my-test-error',
4646
],
4747
]));
4848

4949
$this->expectException(ApiException::class);
50-
$this->expectExceptionMessage('5: my-test-error');
51-
$this->expectExceptionCode(5);
50+
$this->expectExceptionMessage('TestExceptionCode: my-test-error');
5251

5352
$client->prepareResponse($response, new class() {
5453
});

0 commit comments

Comments
 (0)