Skip to content

Commit 6e2e538

Browse files
committed
Update docs for exceptions
1 parent bf32d21 commit 6e2e538

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docs/docs/usage.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,22 @@ if ($owm->wasCached()) {
9595

9696
## Exception handling
9797

98-
Make sure to handle exceptions appropriately. Whenever the OpenWeatherMap API
99-
returns an exception, it is converted into an instance of
100-
`Cmfcmf\OpenWeatherMap\Exception`. If anything else goes wrong, an exception
101-
inheriting from `\Exception` is thrown.
98+
Make sure to handle exceptions appropriately.
99+
Whenever the OpenWeatherMap API returns an exception, it is converted into an instance of
100+
`Cmfcmf\OpenWeatherMap\Exception`.
101+
As a special case, the API will throw a `Cmfcmf\OpenWeatherMap\NotFoundException` if the city/location/coordinates you are querying cannot be found. This exception inherits from `Cmfcmf\OpenWeatherMap\Exception`.
102+
103+
If anything else goes wrong, an exception inheriting from `\Exception` is thrown.
102104

103105
```php {5,7}
104106
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
107+
use Cmfcmf\OpenWeatherMap\NotFoundException as OWMNotFoundException;
105108

106109
try {
107110
$weather = $owm->getWeather('Berlin');
111+
} catch (OWMNotFoundException $e) {
112+
// TODO: Handle "city was not found" exception
113+
// You can opt to skip the handler for `OWMNotFoundException`, because it extends `OWMException`.
108114
} catch (OWMException $e) {
109115
// TODO: Handle API exception
110116
} catch (\Exception $e) {

0 commit comments

Comments
 (0)