static private void HandleResponse()

in Webapp/SDAF/Controllers/RestHelper.cs [448:467]


        static private void HandleResponse(HttpResponseMessage response, string responseBody)
        {
            if (!response.IsSuccessStatusCode)
            {
                string errorMessage;
                switch (response.StatusCode)
                {
                    case System.Net.HttpStatusCode.Unauthorized:
                        errorMessage = "Unauthorized, please ensure that the MSI/Personal Access Token has sufficient permissions and that it has not expired.";
                        break;
                    case System.Net.HttpStatusCode.NotFound:
                        errorMessage = "Could not find the template.";
                        break;
                    default:
                        errorMessage = JsonDocument.Parse(responseBody).RootElement.GetProperty("message").ToString();
                        break;
                }
                throw new HttpRequestException(errorMessage);
            }
        }