Added a bit more graceful handling of 502 code via error message