Skip to content

Commit

Permalink
Merge pull request #1 from Holicz/upgrade-simple-exception
Browse files Browse the repository at this point in the history
Update holicz/simple-eception
  • Loading branch information
Holicz authored Jan 26, 2021
2 parents a6d9909 + 7091132 commit 0354f50
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": "^7.4",
"ext-json": "*",
"holicz/simple-exception": "^1.1",
"holicz/simple-exception": "^2.0",
"thecodingmachine/safe": "1.1"
},
"require-dev": {
Expand Down
20 changes: 11 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Adapter/PvgisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function parsePvgisResponse(string $response): ElectricityProduction
$electricityProduction->addMonthlyProduction($month['month'], $this->multiplier * $month['E_m']);
}
} catch (Exception $e) {
throw new InvalidResponseFormatException(['response' => $response]);
throw new InvalidResponseFormatException();
}

return $electricityProduction;
Expand Down
7 changes: 2 additions & 5 deletions src/Exception/InvalidResponseFormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
final class InvalidResponseFormatException extends BaseException
{
/**
* @param array<string, mixed> $parameters
*
* @throws StringsException
*/
public function __construct(array $parameters = [])
public function __construct()
{
$exceptionContext = new ExceptionContext(
'Nepodařilo se získat informace z evropského Fotovoltaického geografického informačního systému.',
\Safe\sprintf('Pvgis responded with unknown format. Response: %s', $parameters['response']),
$parameters,
\Safe\sprintf('Pvgis responded with unknown format.'),
500
);

Expand Down
6 changes: 1 addition & 5 deletions src/Exception/PvgisResponseFailureException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

final class PvgisResponseFailureException extends BaseException
{
/**
* @param array<string, mixed> $parameters
*/
public function __construct(array $parameters = [])
public function __construct()
{
$exceptionContext = new ExceptionContext(
'Nepodařilo se získat informace z evropského Fotovoltaického geografického informačního systému.',
'Failed to get response from Pvgis API',
$parameters,
500
);

Expand Down

0 comments on commit 0354f50

Please sign in to comment.