Skip to content

Commit

Permalink
Merge pull request #1 from experius/bugfix/SEL-643_catch-postcode-errors
Browse files Browse the repository at this point in the history
[BUGFIX][SEL-643] Catch postcode errors instead of serving server errors
  • Loading branch information
experius-nl authored and MatthijsBreed committed Nov 19, 2021
2 parents a159933 + 41b3825 commit ccc9dc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.0.2 (2021-11-19)

[View Release]([email protected]:experius/Mage2-Module-Experius-PostcodeGraphQl.git/commits/tag/2.0.2)

* [BUGFIX][SEL-643] Catch postcode errors instead of serving server errors *(Matthijs Breed)*


## 2.0.1 (2021-09-28)

[View Release]([email protected]:experius/Mage2-Module-Experius-PostcodeGraphQl.git/commits/tag/2.0.1)
Expand Down
9 changes: 6 additions & 3 deletions Model/Resolver/Postcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Experius\PostcodeGraphQl\Model\Resolver;

use Experius\Core\Helper\Settings;
use Flekto\Postcode\Helper\Exception\ClientException;
use Flekto\Postcode\Helper\PostcodeApiClient;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
Expand Down Expand Up @@ -60,10 +61,12 @@ public function resolve(
$args['houseNumberAddition'] = '';
}

$result = $this->postcodeHelper->dutchAddressByPostcode($args['postcode'], $args['houseNumber'], $args['houseNumberAddition']);
if (isset($result['message'])) {
throw new GraphQlInputException($result['message']);
try {
$result = $this->postcodeHelper->dutchAddressByPostcode($args['postcode'], $args['houseNumber'], $args['houseNumberAddition']);
} catch (ClientException $e) {
throw new GraphQlInputException(__($e->getMessage()));
}

return $result;
}
}

0 comments on commit ccc9dc9

Please sign in to comment.