private static ExitCode HandleException(DropboxException ex) { Console.WriteLine("An error occurred and your file was not uploaded."); Console.WriteLine(ex.StatusCode); Console.WriteLine(ex.Response); switch(ex.StatusCode) { case HttpStatusCode.Unauthorized: return ExitCode.AccessDenied; case HttpStatusCode.Conflict: // Shouldn't happen with the DropNet defaults (overwrite = true), but just in case return ExitCode.FileExists; } return ExitCode.UnknownError; }
/// <summary> /// DropboxException hides the true error in other properties /// </summary> private Exception CreateUsableExceptionFrom(DropboxException ex) { return new Exception("Dropbox error " + ex.Response.ReasonPhrase + " (" + ex.StatusCode + ")", ex); }