Skip to content

Commit 4d5e556

Browse files
authored
Merge pull request #133 from 5am-code/fix/notion-exception-null-error
fix null error during creation of NotionException
2 parents ee3f9ca + d670a64 commit 4d5e556

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Exceptions/NotionException.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace FiveamCode\LaravelNotionApi\Exceptions;
44

55
use Illuminate\Http\Client\Response;
6+
use Illuminate\Support\Arr;
67

78
/**
89
* Class NotionException.
@@ -44,11 +45,11 @@ public static function fromResponse(Response $response): NotionException
4445
$responseBody = json_decode($response->getBody()->getContents(), true);
4546

4647
$errorCode = $errorMessage = '';
47-
if (array_key_exists('code', $responseBody)) {
48+
if (Arr::exists($responseBody ?? [], 'code')) {
4849
$errorCode = "({$responseBody['code']})";
4950
}
5051

51-
if (array_key_exists('code', $responseBody)) {
52+
if (Arr::exists($responseBody ?? [], 'code')) {
5253
$errorMessage = "({$responseBody['message']})";
5354
}
5455

0 commit comments

Comments
 (0)