Change meaning of Outcome::Bad.

This commit is contained in:
Sergio Benitez 2016-09-21 18:31:26 -07:00
parent 81fbc0625d
commit 53e5377482
2 changed files with 10 additions and 6 deletions

View File

@ -7,8 +7,8 @@ use std::fmt;
pub enum Outcome<'h> {
/// Signifies a response that completed sucessfully.
Complete,
/// Signifies a response that completed unsuccessfully.
Bad,
/// Signifies a response that failed internally.
Bad(HyperResponse<'h, HyperFresh>),
/// Signifies a failing response where no further processing should happen.
FailStop,
/// Signifies a failing response whose request should be processed further.
@ -20,7 +20,7 @@ impl<'h> Outcome<'h> {
match *self {
Outcome::Complete => "Complete",
Outcome::FailStop => "FailStop",
Outcome::Bad => "Bad",
Outcome::Bad(..) => "Bad",
Outcome::FailForward(..) => "FailForward",
}
}
@ -28,7 +28,7 @@ impl<'h> Outcome<'h> {
fn as_int(&self) -> isize {
match *self {
Outcome::Complete => 0,
Outcome::Bad => 1,
Outcome::Bad(..) => 1,
Outcome::FailStop => 2,
Outcome::FailForward(..) => 3,
}
@ -53,7 +53,7 @@ impl<'h> fmt::Display for Outcome<'h> {
Outcome::Complete => {
write!(f, "{}", Green.paint("Complete"))
},
Outcome::Bad => {
Outcome::Bad(..) => {
write!(f, "{}", Yellow.paint("Bad Completion"))
},
Outcome::FailStop => {

View File

@ -63,8 +63,12 @@ impl Rocket {
// Get the result if we failed forward so we can try again.
res = match outcome {
Outcome::Complete | Outcome::FailStop | Outcome::Bad => return,
Outcome::Complete | Outcome::FailStop => return,
Outcome::FailForward(r) => r,
Outcome::Bad(r) => {
let reason = "Reason: bad response.";
return self.handle_internal_error(reason, &request, r)
}
};
}