Skip to content

Commit c1073f5

Browse files
authored
Merge pull request #51 from programmatordev/OPA-53-change-docblock-to-throw-only-apierrorexception
Change docblock to throw ApiErrorException
2 parents 0f52285 + a10b6b4 commit c1073f5

File tree

5 files changed

+18
-85
lines changed

5 files changed

+18
-85
lines changed

src/Endpoint/AbstractEndpoint.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ProgrammatorDev\OpenWeatherMap\Config;
99
use ProgrammatorDev\OpenWeatherMap\Endpoint\Util\CacheTtlTrait;
1010
use ProgrammatorDev\OpenWeatherMap\Entity\Error;
11+
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
1112
use ProgrammatorDev\OpenWeatherMap\Exception\BadRequestException;
1213
use ProgrammatorDev\OpenWeatherMap\Exception\NotFoundException;
1314
use ProgrammatorDev\OpenWeatherMap\Exception\TooManyRequestsException;
@@ -53,11 +54,7 @@ public function __construct(protected OpenWeatherMap $api)
5354

5455
/**
5556
* @throws Exception
56-
* @throws BadRequestException
57-
* @throws NotFoundException
58-
* @throws TooManyRequestsException
59-
* @throws UnauthorizedException
60-
* @throws UnexpectedErrorException
57+
* @throws ApiErrorException
6158
*/
6259
protected function sendRequest(
6360
string $method,
@@ -106,11 +103,7 @@ private function configurePlugins(): void
106103
}
107104

108105
/**
109-
* @throws NotFoundException
110-
* @throws UnexpectedErrorException
111-
* @throws TooManyRequestsException
112-
* @throws UnauthorizedException
113-
* @throws BadRequestException
106+
* @throws ApiErrorException
114107
*/
115108
private function handleResponseErrors(ResponseInterface $response): void
116109
{

src/Endpoint/AirPollutionEndpoint.php

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@
55
use Http\Client\Exception;
66
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollutionLocationList;
77
use ProgrammatorDev\OpenWeatherMap\Entity\AirPollution\AirPollutionLocation;
8-
use ProgrammatorDev\OpenWeatherMap\Exception\BadRequestException;
9-
use ProgrammatorDev\OpenWeatherMap\Exception\NotFoundException;
10-
use ProgrammatorDev\OpenWeatherMap\Exception\TooManyRequestsException;
11-
use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
12-
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
8+
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
139
use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
1410
use ProgrammatorDev\YetAnotherPhpValidator\Validator;
1511

1612
class AirPollutionEndpoint extends AbstractEndpoint
1713
{
1814
/**
1915
* @throws Exception
20-
* @throws BadRequestException
21-
* @throws NotFoundException
22-
* @throws TooManyRequestsException
23-
* @throws UnauthorizedException
24-
* @throws UnexpectedErrorException
16+
* @throws ApiErrorException
2517
* @throws ValidationException
2618
*/
2719
public function getCurrent(float $latitude, float $longitude): AirPollutionLocation
@@ -43,11 +35,7 @@ public function getCurrent(float $latitude, float $longitude): AirPollutionLocat
4335

4436
/**
4537
* @throws Exception
46-
* @throws BadRequestException
47-
* @throws NotFoundException
48-
* @throws TooManyRequestsException
49-
* @throws UnauthorizedException
50-
* @throws UnexpectedErrorException
38+
* @throws ApiErrorException
5139
* @throws ValidationException
5240
*/
5341
public function getForecast(float $latitude, float $longitude): AirPollutionLocationList
@@ -69,11 +57,7 @@ public function getForecast(float $latitude, float $longitude): AirPollutionLoca
6957

7058
/**
7159
* @throws Exception
72-
* @throws BadRequestException
73-
* @throws NotFoundException
74-
* @throws TooManyRequestsException
75-
* @throws UnauthorizedException
76-
* @throws UnexpectedErrorException
60+
* @throws ApiErrorException
7761
* @throws ValidationException
7862
*/
7963
public function getHistory(

src/Endpoint/GeocodingEndpoint.php

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
use Http\Client\Exception;
66
use ProgrammatorDev\OpenWeatherMap\Entity\Geocoding\ZipCodeLocation;
77
use ProgrammatorDev\OpenWeatherMap\Entity\Location;
8-
use ProgrammatorDev\OpenWeatherMap\Exception\BadRequestException;
9-
use ProgrammatorDev\OpenWeatherMap\Exception\NotFoundException;
10-
use ProgrammatorDev\OpenWeatherMap\Exception\TooManyRequestsException;
11-
use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
12-
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
8+
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
139
use ProgrammatorDev\OpenWeatherMap\Util\CreateEntityListTrait;
1410
use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
1511
use ProgrammatorDev\YetAnotherPhpValidator\Validator;
@@ -25,11 +21,7 @@ class GeocodingEndpoint extends AbstractEndpoint
2521
/**
2622
* @return Location[]
2723
* @throws Exception
28-
* @throws BadRequestException
29-
* @throws NotFoundException
30-
* @throws TooManyRequestsException
31-
* @throws UnauthorizedException
32-
* @throws UnexpectedErrorException
24+
* @throws ApiErrorException
3325
* @throws ValidationException
3426
*/
3527
public function getByLocationName(string $locationName, int $numResults = self::NUM_RESULTS): array
@@ -51,11 +43,7 @@ public function getByLocationName(string $locationName, int $numResults = self::
5143

5244
/**
5345
* @throws Exception
54-
* @throws BadRequestException
55-
* @throws NotFoundException
56-
* @throws TooManyRequestsException
57-
* @throws UnauthorizedException
58-
* @throws UnexpectedErrorException
46+
* @throws ApiErrorException
5947
* @throws ValidationException
6048
*/
6149
public function getByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
@@ -77,11 +65,7 @@ public function getByZipCode(string $zipCode, string $countryCode): ZipCodeLocat
7765
/**
7866
* @return Location[]
7967
* @throws Exception
80-
* @throws BadRequestException
81-
* @throws NotFoundException
82-
* @throws TooManyRequestsException
83-
* @throws UnauthorizedException
84-
* @throws UnexpectedErrorException
68+
* @throws ApiErrorException
8569
* @throws ValidationException
8670
*/
8771
public function getByCoordinate(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): array

src/Endpoint/OneCallEndpoint.php

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
use ProgrammatorDev\OpenWeatherMap\Entity\OneCall\WeatherAggregate;
99
use ProgrammatorDev\OpenWeatherMap\Entity\OneCall\WeatherLocation;
1010
use ProgrammatorDev\OpenWeatherMap\Entity\OneCall\OneCall;
11-
use ProgrammatorDev\OpenWeatherMap\Exception\BadRequestException;
12-
use ProgrammatorDev\OpenWeatherMap\Exception\NotFoundException;
13-
use ProgrammatorDev\OpenWeatherMap\Exception\TooManyRequestsException;
14-
use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
15-
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
11+
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
1612
use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
1713
use ProgrammatorDev\YetAnotherPhpValidator\Validator;
1814

@@ -23,11 +19,7 @@ class OneCallEndpoint extends AbstractEndpoint
2319

2420
/**
2521
* @throws Exception
26-
* @throws BadRequestException
27-
* @throws NotFoundException
28-
* @throws TooManyRequestsException
29-
* @throws UnauthorizedException
30-
* @throws UnexpectedErrorException
22+
* @throws ApiErrorException
3123
* @throws ValidationException
3224
*/
3325
public function getWeather(float $latitude, float $longitude): OneCall
@@ -51,11 +43,7 @@ public function getWeather(float $latitude, float $longitude): OneCall
5143

5244
/**
5345
* @throws Exception
54-
* @throws BadRequestException
55-
* @throws NotFoundException
56-
* @throws TooManyRequestsException
57-
* @throws UnauthorizedException
58-
* @throws UnexpectedErrorException
46+
* @throws ApiErrorException
5947
* @throws ValidationException
6048
*/
6149
public function getHistoryMoment(float $latitude, float $longitude, \DateTimeInterface $dateTime): WeatherLocation
@@ -81,11 +69,7 @@ public function getHistoryMoment(float $latitude, float $longitude, \DateTimeInt
8169

8270
/**
8371
* @throws Exception
84-
* @throws BadRequestException
85-
* @throws NotFoundException
86-
* @throws TooManyRequestsException
87-
* @throws UnauthorizedException
88-
* @throws UnexpectedErrorException
72+
* @throws ApiErrorException
8973
* @throws ValidationException
9074
*/
9175
public function getHistoryAggregate(float $latitude, float $longitude, \DateTimeInterface $date): WeatherAggregate

src/Endpoint/WeatherEndpoint.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
use ProgrammatorDev\OpenWeatherMap\Endpoint\Util\UnitSystemTrait;
88
use ProgrammatorDev\OpenWeatherMap\Entity\Weather\WeatherLocation;
99
use ProgrammatorDev\OpenWeatherMap\Entity\Weather\WeatherLocationList;
10-
use ProgrammatorDev\OpenWeatherMap\Exception\BadRequestException;
11-
use ProgrammatorDev\OpenWeatherMap\Exception\NotFoundException;
12-
use ProgrammatorDev\OpenWeatherMap\Exception\TooManyRequestsException;
13-
use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
14-
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
10+
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
1511
use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException;
1612
use ProgrammatorDev\YetAnotherPhpValidator\Validator;
1713

@@ -24,11 +20,7 @@ class WeatherEndpoint extends AbstractEndpoint
2420

2521
/**
2622
* @throws Exception
27-
* @throws BadRequestException
28-
* @throws NotFoundException
29-
* @throws TooManyRequestsException
30-
* @throws UnauthorizedException
31-
* @throws UnexpectedErrorException
23+
* @throws ApiErrorException
3224
* @throws ValidationException
3325
*/
3426
public function getCurrent(float $latitude, float $longitude): WeatherLocation
@@ -52,11 +44,7 @@ public function getCurrent(float $latitude, float $longitude): WeatherLocation
5244

5345
/**
5446
* @throws Exception
55-
* @throws BadRequestException
56-
* @throws NotFoundException
57-
* @throws TooManyRequestsException
58-
* @throws UnauthorizedException
59-
* @throws UnexpectedErrorException
47+
* @throws ApiErrorException
6048
* @throws ValidationException
6149
*/
6250
public function getForecast(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): WeatherLocationList

0 commit comments

Comments
 (0)