Skip to content

Commit

Permalink
fix: error when Notion sends an empty response (#290)
Browse files Browse the repository at this point in the history
Closes #289
  • Loading branch information
mariosimao authored Sep 25, 2023
1 parent c15f694 commit 932f819
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.11.1] 2023-08-02
## Fixed
- Error when Notion sends an empty response (#289)
### Build
- Bump brianium/paratest from 7.2.3 to 7.2.4 (#274)
- Bump vimeo/psalm from 5.14.0 to 5.14.1 (#275)
- Bump brianium/paratest from 7.2.4 to 7.2.5 (#277)
- Bump phpunit/phpunit from 10.3.1 to 10.3.2 (#278)
- Bump vimeo/psalm from 5.14.1 to 5.15.0 (#279)
- Bump guzzlehttp/guzzle from 7.7.0 to 7.8.0 (#280)
- Bump brianium/paratest from 7.2.5 to 7.2.6 (#283)
- Bump phpunit/phpunit from 10.3.2 to 10.3.3 (#284)
- Bump phpunit/phpunit from 10.3.3 to 10.3.4 (#286)
- Bump brianium/paratest from 7.2.6 to 7.2.7 (#288)
- Bump infection/infection from 0.27.0 to 0.27.2 (#287)

## [v1.11.0] 2023-08-02

### Added
Expand Down Expand Up @@ -400,4 +416,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[1.9.0]: https://github.com/mariosimao/notion-sdk-php/releases/tag/v1.9.0
[1.10.0]: https://github.com/mariosimao/notion-sdk-php/releases/tag/v1.10.0
[1.11.0]: https://github.com/mariosimao/notion-sdk-php/releases/tag/v1.11.0
[Unreleased]: https://github.com/mariosimao/notion-sdk-php/compare/v1.11.0...HEAD
[1.11.1]: https://github.com/mariosimao/notion-sdk-php/releases/tag/v1.11.1
[Unreleased]: https://github.com/mariosimao/notion-sdk-php/compare/v1.11.1...HEAD
6 changes: 5 additions & 1 deletion src/Exceptions/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ final public function __construct(

final public static function fromResponse(ResponseInterface $response): static
{
/** @var array{ message: string, code: string} $body */
/** @var array{ message: string, code: string}|false|null $body */
$body = json_decode((string) $response->getBody(), true);

if ($body === null || $body === false) {
return new static("", "", $response);
}

return match ($body["code"]) {
"conflict_error" => new ConflictException($body["message"], $body["code"], $response),
default => new static($body["message"], $body["code"], $response),
Expand Down

0 comments on commit 932f819

Please sign in to comment.