Added conditions for custom status codes and also preserving code from Exception.