webdriver: Add an implementation of From<DecoderError> for WebDriverError
authorJames Graham <james@hoppipolla.co.uk>
Thu, 10 Dec 2015 10:51:47 +0000
changeset 428050 16c0815fd1adc43906c87421a870127415c6974d
parent 428049 8b6c323aba2a0f284d497283d017848eda106048
child 428051 5cc8b2ed8a3074cb30db61101916fc32696efc21
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone57.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
webdriver: Add an implementation of From<DecoderError> for WebDriverError Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 55c965d72180ecde14bd0b039ea339b89d87a20f
testing/webdriver/src/error.rs
--- a/testing/webdriver/src/error.rs
+++ b/testing/webdriver/src/error.rs
@@ -1,10 +1,10 @@
 use hyper::status::StatusCode;
-use rustc_serialize::json::{Json, ToJson, ParserError};
+use rustc_serialize::json::{Json, ToJson, ParserError, DecoderError};
 use std::collections::BTreeMap;
 use std::convert::From;
 use std::error::Error;
 use std::fmt;
 use std::io::Error as IoError;
 
 #[derive(PartialEq, Debug)]
 pub enum ErrorStatus {
@@ -166,8 +166,16 @@ impl From<ParserError> for WebDriverErro
 }
 
 impl From<IoError> for WebDriverError {
     fn from(err: IoError) -> WebDriverError {
         WebDriverError::new(ErrorStatus::UnknownError,
                             err.description())
     }
 }
+
+impl From<DecoderError> for WebDriverError {
+    fn from(err: DecoderError) -> WebDriverError {
+        WebDriverError::new(ErrorStatus::UnknownError,
+                            &format!(
+                                "Could not decode json string:\n{}", err.description())[..])
+    }
+}