##// 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 66 #[derive(Debug)]
67 pub struct ConfigValueParseError {
67 pub struct ConfigValueParseErrorDetails {
68 68 pub origin: ConfigOrigin,
69 69 pub line: Option<usize>,
70 70 pub section: Vec<u8>,
@@ -73,6 +73,9 b' pub struct ConfigValueParseError {'
73 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 79 impl fmt::Display for ConfigValueParseError {
77 80 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78 81 // TODO: add origin and line number information, here and in
@@ -354,14 +357,14 b' impl Config {'
354 357 match self.get_inner(section, item) {
355 358 Some((layer, v)) => match parse(&v.bytes) {
356 359 Some(b) => Ok(Some(b)),
357 None => Err(ConfigValueParseError {
360 None => Err(Box::new(ConfigValueParseErrorDetails {
358 361 origin: layer.origin.to_owned(),
359 362 line: v.line,
360 363 value: v.bytes.to_owned(),
361 364 section: section.to_owned(),
362 365 item: item.to_owned(),
363 366 expected_type,
364 }),
367 })),
365 368 },
366 369 None => Ok(None),
367 370 }
General Comments 0
You need to be logged in to leave comments. Login now