|
@@ 170-174 (lines=5) @@
|
| 167 |
|
// Invalid xml format. This happens in case OpenWeatherMap returns an error. |
| 168 |
|
// OpenWeatherMap always uses json for errors, even if one specifies xml as format. |
| 169 |
|
$error = json_decode($answer, true); |
| 170 |
|
if (isset($error['message'])) { |
| 171 |
|
throw new OWMException($error['message'], $error['cod']); |
| 172 |
|
} else { |
| 173 |
|
throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); |
| 174 |
|
} |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
return new CurrentWeather($xml, $units); |
|
@@ 240-244 (lines=5) @@
|
| 237 |
|
// Invalid xml format. This happens in case OpenWeatherMap returns an error. |
| 238 |
|
// OpenWeatherMap always uses json for errors, even if one specifies xml as format. |
| 239 |
|
$error = json_decode($answer, true); |
| 240 |
|
if (isset($error['message'])) { |
| 241 |
|
throw new OWMException($error['message'], $error['cod']); |
| 242 |
|
} else { |
| 243 |
|
throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer); |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
return new WeatherForecast($xml, $units, $days); |