Bug 1411026 - Rename MarionetteError::status to ::code. r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Mon, 23 Oct 2017 21:53:06 +0100
changeset 387916 6a24cb5cb401a04086a19ebfc1224099fccc0dc3
parent 387915 135d220e21783e0f4d892687594aedd672ba13da
child 387917 7d3f5015ac7e35796e6b3595e56d20cec64b9ff0
push id32739
push useracraciun@mozilla.com
push dateWed, 25 Oct 2017 09:29:21 +0000
treeherdermozilla-central@252a8528c5ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1411026
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1411026 - Rename MarionetteError::status to ::code. r=whimboo For errors originating from Marionette we talk about "error codes", not about "error statuses". This patch fixes the JSON serialisation method Marionette::to_json which incorrectly serialised the error code as "status"; it should be "error". This also removes the MarionetteError::new constructor as we have no need to allow explicit construction of MarionetteError's. MozReview-Commit-ID: 7gjz0ebkMIU
testing/geckodriver/src/marionette.rs
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -1249,63 +1249,55 @@ impl ToJson for MarionetteResponse {
     fn to_json(&self) -> Json {
         Json::Array(vec![Json::U64(1), self.id.to_json(), self.error.to_json(),
                          self.result.clone()])
     }
 }
 
 #[derive(RustcEncodable, RustcDecodable)]
 pub struct MarionetteError {
-    pub status: String,
+    pub code: String,
     pub message: String,
     pub stacktrace: Option<String>
 }
 
 impl MarionetteError {
-    fn new(status: String, message: String, stacktrace: Option<String>) -> MarionetteError {
-        MarionetteError {
-            status: status,
-            message: message,
-            stacktrace: stacktrace
-        }
-    }
-
     fn from_json(data: &Json) -> WebDriverResult<MarionetteError> {
         if !data.is_object() {
             return Err(WebDriverError::new(ErrorStatus::UnknownError,
                                            "Expected an error object"));
         }
-        let status = try_opt!(
+
+        let code = try_opt!(
             try_opt!(data.find("error"),
                      ErrorStatus::UnknownError,
-                     "Error value has no status").as_string(),
+                     "Error value has no error code").as_string(),
             ErrorStatus::UnknownError,
             "Error status was not a string").into();
-
         let message = try_opt!(
             try_opt!(data.find("message"),
                      ErrorStatus::UnknownError,
                      "Error value has no message").as_string(),
             ErrorStatus::UnknownError,
             "Error message was not a string").into();
-
         let stacktrace = match data.find("stacktrace") {
             None | Some(&Json::Null) => None,
             Some(x) => Some(try_opt!(x.as_string(),
                                      ErrorStatus::UnknownError,
                                      "Error message was not a string").into()),
         };
-        Ok(MarionetteError::new(status, message, stacktrace))
+
+        Ok(MarionetteError { code, message, stacktrace })
     }
 }
 
 impl ToJson for MarionetteError {
     fn to_json(&self) -> Json {
         let mut data = BTreeMap::new();
-        data.insert("status".into(), self.status.to_json());
+        data.insert("error".into(), self.code.to_json());
         data.insert("message".into(), self.message.to_json());
         data.insert("stacktrace".into(), self.stacktrace.to_json());
         Json::Object(data)
     }
 }
 
 fn get_free_port() -> IoResult<u16> {
     TcpListener::bind(&("localhost", 0))