summaryrefslogtreecommitdiff
path: root/src/de/mod.rs
diff options
context:
space:
mode:
authorSam Scott <sam.scott89@gmail.com>2017-05-21 16:11:15 +0100
committerSam Scott <sam.scott89@gmail.com>2017-05-21 16:11:56 +0100
commit61b7b7075227f25f509e0ca51909e0f873ed310f (patch)
treed533ffece20e8dc833cb6f32a0932bf2fbede511 /src/de/mod.rs
parent6429b975c6cbcf5d7e0c2b1d02026f8d46b5c50f (diff)
Refactor errors to be of a single type and export it.
Diffstat (limited to 'src/de/mod.rs')
-rw-r--r--src/de/mod.rs34
1 files changed, 4 insertions, 30 deletions
diff --git a/src/de/mod.rs b/src/de/mod.rs
index cf2768b..228a12b 100644
--- a/src/de/mod.rs
+++ b/src/de/mod.rs
@@ -41,8 +41,8 @@
mod parse;
pub use de::parse::Config;
+use error::*;
-use data_encoding;
use data_encoding::base64url as base64;
use serde::de;
@@ -51,33 +51,7 @@ use serde::de::IntoDeserializer;
use url::percent_encoding;
use std::collections::btree_map::{BTreeMap, Entry, IntoIter};
-use std::io::{self,Read};
-use std::fmt::Display;
-use std::string;
-
-error_chain! {
- errors { Custom(msg: String) }
- foreign_links {
- Decoding(data_encoding::decode::Error);
- Io(io::Error);
- Utf8(string::FromUtf8Error);
- }
-}
-
-impl Error {
- fn top_level(object: &'static str) -> Self {
- ErrorKind::Custom(format!("cannot deserialize {} at the top level.\
- Try deserializing into a struct.", object)).into()
-
- }
-}
-
-impl de::Error for Error {
- fn custom<T>(msg: T) -> Self
- where T: Display {
- ErrorKind::Custom(msg.to_string()).into()
- }
-}
+use std::io::Read;
/// Deserializes a querystring from a `&[u8]`.
///
@@ -316,7 +290,7 @@ impl<'de> de::MapAccess<'de> for QsDeserializer {
}
impl<'de> de::EnumAccess<'de> for QsDeserializer {
- type Error = Error;
+ type Error = Error;
type Variant = Self;
fn variant_seed<V>(mut self, seed: V) -> Result<(V::Value, Self::Variant)>
@@ -379,7 +353,7 @@ impl<'de> de::VariantAccess<'de> for QsDeserializer {
}
impl<'de> de::EnumAccess<'de> for LevelDeserializer {
- type Error = Error;
+ type Error = Error;
type Variant = Self;
fn variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant)>