|
101 | 101 | //! Result::HttpError(err) => println!("HTTPERROR: {:?}", err), |
102 | 102 | //! Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"), |
103 | 103 | //! Result::MissingToken => println!("OAuth2: Missing Token"), |
| 104 | +//! Result::Cancelled => println!("Operation cancelled by user"), |
104 | 105 | //! Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size), |
105 | 106 | //! Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"), |
106 | 107 | //! Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field), |
@@ -266,6 +267,7 @@ impl Default for Scope { |
266 | 267 | /// Result::HttpError(err) => println!("HTTPERROR: {:?}", err), |
267 | 268 | /// Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"), |
268 | 269 | /// Result::MissingToken => println!("OAuth2: Missing Token"), |
| 270 | +/// Result::Cancelled => println!("Operation cancelled by user"), |
269 | 271 | /// Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size), |
270 | 272 | /// Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"), |
271 | 273 | /// Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field), |
@@ -583,8 +585,7 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network |
583 | 585 | if !res.status.is_success() { |
584 | 586 | let mut json_err = String::new(); |
585 | 587 | res.read_to_string(&mut json_err).unwrap(); |
586 | | - let error_info: cmn::JsonServerError = json::from_str(&json_err).unwrap(); |
587 | | - if let oauth2::Retry::After(d) = dlg.http_failure(&res, Some(error_info)) { |
| 588 | + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { |
588 | 589 | sleep(d); |
589 | 590 | continue; |
590 | 591 | } |
@@ -618,11 +619,21 @@ impl<'a, C, NC, A> ArchiveInsertCall<'a, C, NC, A> where NC: hyper::net::Network |
618 | 619 | }.upload() |
619 | 620 | }; |
620 | 621 | match upload_result { |
621 | | - Err(err) => { |
| 622 | + None => { |
| 623 | + dlg.finished(false); |
| 624 | + return Result::Cancelled |
| 625 | + } |
| 626 | + Some(Err(err)) => { |
622 | 627 | dlg.finished(false); |
623 | 628 | return Result::HttpError(err) |
624 | 629 | } |
625 | | - Ok(upload_result) => res = upload_result, |
| 630 | + Some(Ok(upload_result)) => { |
| 631 | + res = upload_result; |
| 632 | + if !res.status.is_success() { |
| 633 | + dlg.finished(false); |
| 634 | + return Result::Failure(res) |
| 635 | + } |
| 636 | + } |
626 | 637 | } |
627 | 638 | } |
628 | 639 | let result_value = { |
|
0 commit comments