summaryrefslogtreecommitdiffstats
path: root/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/component.rs')
-rw-r--r--src/component.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/component.rs b/src/component.rs
index 8330d18..f6d9ac0 100644
--- a/src/component.rs
+++ b/src/component.rs
@@ -2,7 +2,7 @@ use std::str::FromStr;
use std::collections::BTreeMap;
use property::Property;
-use parser::Parser;
+use parser::{Parser, ParseErrorReason};
use error::*;
@@ -69,29 +69,28 @@ impl Component {
}
impl FromStr for Component {
- type Err = VObjectErrorKind;
+ type Err = VObjectError;
/// Same as `vobject::parse_component`
- fn from_str(s: &str) -> Result<Component> {
+ fn from_str(s: &str) -> VObjectResult<Component> {
parse_component(s)
}
}
/// Parse exactly one component. Trailing data generates errors.
-pub fn parse_component(s: &str) -> Result<Component> {
- let (rv, new_s) = try!(read_component(s));
+pub fn parse_component(s: &str) -> VObjectResult<Component> {
+ let (rv, new_s) = read_component(s)?;
if !new_s.is_empty() {
- let s = format!("Trailing data: `{}`", new_s);
- return Err(VObjectErrorKind::ParserError(s));
+ return Err(ParseErrorReason::TrailingData(new_s.into()).into());
}
Ok(rv)
}
/// Parse one component and return the rest of the string.
-pub fn read_component(s: &str) -> Result<(Component, &str)> {
+pub fn read_component(s: &str) -> VObjectResult<(Component, &str)> {
let mut parser = Parser::new(s);
- let rv = try!(parser.consume_component());
+ let rv = parser.consume_component()?;
let new_s = if parser.eof() {
""
} else {