title: OpenWeatherMap api is not returning associative array for errors
body: <p>I'm using OpenWeatherMap API and the API is working completely fine when I passed the valid city and API key but let's say someone entered the wrong city or API, it would return the following errors 401 and 404</p>
  <p>but instead of returning those errors in an associative array (json_decode), it is returning this error</p>
  <p>failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized</p>
  <p>I'm trying to get those errors in an associative array format for validation</p>
  <pre><code>    $weather_api = file_get_contents(&quot;https://api.openweathermap.org/data/2.5/weather?q={city}&amp;appid={api_key}&quot;);
      $weather_data = json_decode($weather_api, true);
        
      echo &quot;&lt;pre&gt;&quot;;
      echo print_r($weather_data);
      echo &quot;&lt;/pre&gt;&quot;;
  </code></pre>
  <p>What am I doing wrong?</p>