void ReadErrorObject()

in Gems/AWSCore/Code/Include/Framework/ServiceRequestJob.h [420:470]


        void ReadErrorObject(int responseCode, JsonInputStream& stream)
        {
            AZStd::string parseErrorMessage;
            bool ok = JsonReader::ReadObject(stream, RequestType::error, parseErrorMessage);
            ok = ok && !RequestType::error.message.empty();
            ok = ok && !RequestType::error.type.empty();
            if (!ok)
            {
                if (responseCode < 400)
                {
                    // Not expected to make it here: 100 (info), 200 (success), or 300 (redirect).
                    RequestType::error.type = Error::TYPE_CONTENT_ERROR;
                    RequestType::error.message = AZStd::string::format("Unexpected response code %i received. %s", responseCode, stream.GetContent().c_str());
                }
                else if (responseCode < 500)
                {
                    RequestType::error.type = Error::TYPE_CLIENT_ERROR;
                    switch (responseCode)
                    {
                    case 401:
                    case 403:
                        RequestType::error.message = AZStd::string::format("Access denied (%i). %s", responseCode, stream.GetContent().c_str());
                        break;
                    case 404:
                        RequestType::error.message = AZStd::string::format("Not found (%i). %s", responseCode, stream.GetContent().c_str());
                        break;
                    case 405:
                        RequestType::error.message = AZStd::string::format("Method not allowed (%i). %s", responseCode, stream.GetContent().c_str());
                        break;
                    case 406:
                        RequestType::error.message = AZStd::string::format("Content not acceptable (%i). %s", responseCode, stream.GetContent().c_str());
                        break;
                    default:
                        RequestType::error.message = AZStd::string::format("Client error (%i). %s", responseCode, stream.GetContent().c_str());
                        break;
                    }
                }
                else if (responseCode < 600)
                {
                    RequestType::error.type = Error::TYPE_SERVICE_ERROR;
                    RequestType::error.message = AZStd::string::format("Service error (%i). %s", responseCode, stream.GetContent().c_str());
                }
                else
                {
                    // Anything above 599 isn't valid HTTP.
                    RequestType::error.type = Error::TYPE_CONTENT_ERROR;
                    RequestType::error.message = AZStd::string::format("Unexpected response code %i received. %s", responseCode, stream.GetContent().c_str());
                }

            }
        }