ref. the query same subject of 17 June 2020 and relevant answer.
- ServiceException apparently is changed and now 'StatusCode' should be replaced by 'ResponseStatusCode'
- I tried to catch it in the procedure to upload large files:
try
{
// Upload the file
var uploadResult = await fileUploadTask.UploadAsync(progress);
sb.AppendLine(uploadResult.UploadSucceeded
? $"Upload complete, item ID: {uploadResult.ItemResponse.Id}"
: "Upload failed");
}
catch (ODataError ex)
{
sb.AppendLine($"Error uploading: {ex.Error?.Message}");
}
catch(ServiceException ex)
{
sb.AppendLine($"Service exception: {ex.Message}");
sb.AppendLine($"StatusCode: {ex.ResponseStatusCode}");
ex.
}
catch (HttpRequestException ex)
{
sb.AppendLine($"HttpException: {ex.Message}");
sb.AppendLine($"HttpRequestError: {ex.HttpRequestError}");
sb.AppendLine($"StatusCode: {ex.StatusCode}");
}
catch (Exception ex)
{
sb.AppendLine(ex.Message);
}
finally
{
result.Text = sb.ToString();
}
Disconnecting the Internet during the upload, I expect should throw ServiceException - but it doesn't. HttpRequestException is thrown instead, but in this case: Message = “An error occurred while sending the request”, HttpRequestError = 0 (unknown), StatusCode = null
So I am stuck with the original query: hot to extract the HTTP status?