You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/usage.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -95,16 +95,22 @@ if ($owm->wasCached()) {
95
95
96
96
## Exception handling
97
97
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.
102
104
103
105
```php {5,7}
104
106
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
107
+
use Cmfcmf\OpenWeatherMap\NotFoundException as OWMNotFoundException;
105
108
106
109
try {
107
110
$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`.
0 commit comments