Skip to content

Commit

Permalink
fix: exchange rates api broke exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
florianv committed Apr 11, 2021
1 parent 5d9aadf commit 3235701
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/Exception/NonBreakingInvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/*
* This file is part of Exchanger.
*
* (c) Florian Voutzinos <florian@voutzinos.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Exchanger\Exception;

/**
* Generic InvalidArgumentException thrown by the library that doesn't break the chain.
*
* @author Florian Voutzinos <florian@voutzinos.com>
*/
class NonBreakingInvalidArgumentException extends \Exception
{
}
3 changes: 2 additions & 1 deletion src/Service/ExchangeRatesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Exchanger\Contract\ExchangeRateQuery;
use Exchanger\Contract\HistoricalExchangeRateQuery;
use Exchanger\Exception\Exception;
use Exchanger\Exception\NonBreakingInvalidArgumentException;
use Exchanger\Exception\UnsupportedCurrencyPairException;
use Exchanger\ExchangeRate;
use Exchanger\StringUtil;
Expand All @@ -43,7 +44,7 @@ final class ExchangeRatesApi extends HttpService
public function processOptions(array &$options): void
{
if (!isset($options[self::ACCESS_KEY_OPTION])) {
throw new \InvalidArgumentException('The "access_key" option must be provided to use exchangeratesapi.io');
throw new NonBreakingInvalidArgumentException('The "access_key" option must be provided to use exchangeratesapi.io');
}

if (!isset($options['enterprise'])) {
Expand Down

0 comments on commit 3235701

Please sign in to comment.