##// END OF EJS Templates
rust: box ConfigValueParseError to avoid large result types...
Arseniy Alekseyev -
r51104:af9d050f default
parent child Browse files
Show More
@@ -64,7 +64,7 b' pub enum ConfigSource {'
64 }
64 }
65
65
66 #[derive(Debug)]
66 #[derive(Debug)]
67 pub struct ConfigValueParseError {
67 pub struct ConfigValueParseErrorDetails {
68 pub origin: ConfigOrigin,
68 pub origin: ConfigOrigin,
69 pub line: Option<usize>,
69 pub line: Option<usize>,
70 pub section: Vec<u8>,
70 pub section: Vec<u8>,
@@ -73,6 +73,9 b' pub struct ConfigValueParseError {'
73 pub expected_type: &'static str,
73 pub expected_type: &'static str,
74 }
74 }
75
75
76 // boxed to avoid very large Result types
77 pub type ConfigValueParseError = Box<ConfigValueParseErrorDetails>;
78
76 impl fmt::Display for ConfigValueParseError {
79 impl fmt::Display for ConfigValueParseError {
77 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
80 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78 // TODO: add origin and line number information, here and in
81 // TODO: add origin and line number information, here and in
@@ -354,14 +357,14 b' impl Config {'
354 match self.get_inner(section, item) {
357 match self.get_inner(section, item) {
355 Some((layer, v)) => match parse(&v.bytes) {
358 Some((layer, v)) => match parse(&v.bytes) {
356 Some(b) => Ok(Some(b)),
359 Some(b) => Ok(Some(b)),
357 None => Err(ConfigValueParseError {
360 None => Err(Box::new(ConfigValueParseErrorDetails {
358 origin: layer.origin.to_owned(),
361 origin: layer.origin.to_owned(),
359 line: v.line,
362 line: v.line,
360 value: v.bytes.to_owned(),
363 value: v.bytes.to_owned(),
361 section: section.to_owned(),
364 section: section.to_owned(),
362 item: item.to_owned(),
365 item: item.to_owned(),
363 expected_type,
366 expected_type,
364 }),
367 })),
365 },
368 },
366 None => Ok(None),
369 None => Ok(None),
367 }
370 }
General Comments 0
You need to be logged in to leave comments. Login now