@@ 200-204 (lines=5) @@ | ||
197 | // Invalid xml format. This happens in case OpenWeatherMap returns an error. |
|
198 | // OpenWeatherMap always uses json for errors, even if one specifies xml as format. |
|
199 | $error = json_decode($answer, true); |
|
200 | if (isset($error['message'])) { |
|
201 | throw new OWMException($error['message'], $error['cod']); |
|
202 | } else { |
|
203 | throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: '.$answer); |
|
204 | } |
|
205 | } |
|
206 | ||
207 | return new CurrentWeather($xml, $units); |
|
@@ 270-274 (lines=5) @@ | ||
267 | // Invalid xml format. This happens in case OpenWeatherMap returns an error. |
|
268 | // OpenWeatherMap always uses json for errors, even if one specifies xml as format. |
|
269 | $error = json_decode($answer, true); |
|
270 | if (isset($error['message'])) { |
|
271 | throw new OWMException($error['message'], $error['cod']); |
|
272 | } else { |
|
273 | throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: '.$answer); |
|
274 | } |
|
275 | } |
|
276 | ||
277 | return new WeatherForecast($xml, $units, $days); |