diff options
author | Andreas Tolfsen <ato@mozilla.com> | 2016-10-26 15:36:48 +0300 |
---|---|---|
committer | jgraham <james@hoppipolla.co.uk> | 2016-11-23 10:35:36 +0300 |
commit | 7d49dbb8c85ecadb669b2fbeb72b2ff366849085 (patch) | |
tree | b96e18c67ef896924748bbcf32381aca51acc58b /src/marionette.rs | |
parent | 3dbe0a93a7ec7525ed6907f853fc6b6af7564a7e (diff) |
marionette: improve browser start logging
This change removes the newline character in error messages related to
setting preferences and starting the browser process as these tend to
make error messages in language bindings look more interesting than they
should be.
It also avoids calling `Error::description()` as this is implied through
the display trait implementation of `Error`.
For `PathBuf` we must apparently call `display()` to invoke its
`fmt::Display`` trait implementation.
The remaining code in `start_browser` is linted with rustfmt.
Diffstat (limited to 'src/marionette.rs')
-rw-r--r-- | src/marionette.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/marionette.rs b/src/marionette.rs index 4edb226..08ab05a 100644 --- a/src/marionette.rs +++ b/src/marionette.rs @@ -350,11 +350,11 @@ impl MarionetteHandler { fn start_browser(&mut self, port: u16, mut options: FirefoxOptions) -> WebDriverResult<()> { let binary = try!(self.binary_path(&mut options) - .ok_or(WebDriverError::new(ErrorStatus::UnknownError, - "Expected browser binary location, \ - but unable to find binary in default location, \ - no 'moz:firefoxOptions.binary' capability provided, \ - and no binary flag set on the command line"))); + .ok_or(WebDriverError::new(ErrorStatus::UnknownError, + "Expected browser binary location, but unable to find \ + binary in default location, no \ + 'moz:firefoxOptions.binary' capability provided, and \ + no binary flag set on the command line"))); let custom_profile = options.profile.is_some(); @@ -366,16 +366,18 @@ impl MarionetteHandler { }; try!(self.set_prefs(port, &mut runner.profile, custom_profile, options.prefs) - .map_err(|e| WebDriverError::new(ErrorStatus::UnknownError, - format!("Failed to set preferences:\n{}", - e.description())))); + .map_err(|e| { + WebDriverError::new(ErrorStatus::UnknownError, + format!("Failed to set preferences: {}", e)) + })); - info!("Starting browser {}", binary.to_string_lossy()); + info!("Starting browser {}", binary.display()); try!(runner.start() - .map_err(|e| WebDriverError::new(ErrorStatus::UnknownError, - format!("Failed to start browser:\n{}", - e.description())))); - + .map_err(|e| { + WebDriverError::new(ErrorStatus::UnknownError, + format!("Failed to start browser {}: {}", + binary.display(), e)) + })); self.browser = Some(runner); Ok(()) |