/// <summary> /// The event handler called by the .NET Client Library to indicate the current status of the upload. /// </summary> /// <param name="uploadStatusInfo">IUploadProgress object passed by upload process</param> static void VideoInsertRequest_ProgressChanged(IUploadProgress uploadStatusInfo) { switch (uploadStatusInfo.Status) { case UploadStatus.Completed: ResumeRetriesCount = Int32.MaxValue; // Ensure that Do..While loop terminates Console.WriteLine("Status: Completed"); break; case UploadStatus.Starting: Console.WriteLine("Status: Starting"); break; case UploadStatus.NotStarted: Console.WriteLine("Status: Not Started"); break; case UploadStatus.Uploading: float sngPercent = 0; ResumeRetriesCount = 0; // Successfully transmitted something so reset resume retries counter if (VideoFileLength > 0) { sngPercent = (float)((100.0 * uploadStatusInfo.BytesSent) / VideoFileLength); } // // Display only whole percents // int p = (int)sngPercent; if (p > ProgressPercent) { // Only report whole percent progress Console.WriteLine(String.Format("Status: Uploading {0:N0}% ({1:N})", p, uploadStatusInfo.BytesSent)); ProgressPercent = p; } break; case UploadStatus.Failed: Google.GoogleApiException APIException = uploadStatusInfo.Exception as Google.GoogleApiException; if ((APIException == null) || (APIException.Error == null)) { Console.WriteLine(string.Format("Upload Failed: {0}", uploadStatusInfo.Exception.Message)); } else { Console.WriteLine(string.Format("Upload Failed: {0}", APIException.Error.ToString())); // Do not retry if the request is in error int StatusCode = (int)APIException.HttpStatusCode; // See https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol if ((StatusCode / 100) == 4 || ((StatusCode / 100) == 5 && !(StatusCode == 500 | StatusCode == 502 | StatusCode == 503 | StatusCode == 504))) { ResumeRetriesCount = Int32.MaxValue; } } break; } }
/// <summary>Capture this exception as log4net FAIL (not ERROR) when logged</summary> public static void LogAsFail(ref Google.GoogleApiException ex) { if (ex.Data.Contains(LogAs)) { ex.Data[LogAs] = OGCSexception.LogLevel.FAIL; } else { ex.Data.Add(LogAs, OGCSexception.LogLevel.FAIL); } }
public static String FriendlyMessage(System.Exception ex) { if (ex is Google.GoogleApiException) { Google.GoogleApiException gaex = ex as Google.GoogleApiException; return(gaex.Error.Message + " [" + gaex.Error.Code + "=" + gaex.HttpStatusCode + "]"); } else { return(ex.Message + (ex.InnerException != null && !(ex.InnerException is Google.GoogleApiException) ? "<br/>" + ex.InnerException.Message : "")); } }
public static String FriendlyMessage(System.Exception ex) { if (ex is Google.GoogleApiException) { Google.GoogleApiException gaex = ex as Google.GoogleApiException; return(gaex.Error.Message + " [" + gaex.Error.Code + "=" + gaex.HttpStatusCode + "]"); } else { return(ex.Message); } }
public static Google.GoogleApiException isNotAFolder(string id, DriveService service) { Google.GoogleApiException notAFolder = new Google.GoogleApiException(service.Name, "File is not a folder :" + id); RequestError error = new RequestError(); error.Code = 400; error.Message = "File is not a folder: " + id; error.Errors = new List <SingleError>() { new SingleError() { Domain = "global", Location = "field", LocationType = "parameter", Message = "File is not a folder: " + id, Reason = "notAFolder" } }; notAFolder.Error = error; return(notAFolder); }
internal void InitializeError(Google.GoogleApiException exception) { isSuccess = false; SetError(exception.Error); }