geckodriver: 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.

Source-Repo: https://github.com/mozilla/geckodriver
Source-Revision: 7d49dbb8c85ecadb669b2fbeb72b2ff366849085

committer: jgraham <james@hoppipolla.co.uk>

--HG--
extra : rebase_source : 3b177cae58c67837fc5196311167c398af273452
This commit is contained in:
Andreas Tolfsen 2016-11-23 07:35:36 +00:00
Родитель 846a8c1adc
Коммит 70c0123149
1 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -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(())