Change public interface to return boxed dynamic error instead of String.
This commit is contained in:
parent
37e85158ea
commit
e4c0e32536
@ -28,7 +28,7 @@ use crate::types::Object;
|
|||||||
///
|
///
|
||||||
/// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document.
|
/// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
|
pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, Box<dyn std::error::Error>> {
|
||||||
parse_with_settings(input, &GlobalSettings::default())
|
parse_with_settings(input, &GlobalSettings::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
|
|||||||
pub fn parse_with_settings<'g, 's>(
|
pub fn parse_with_settings<'g, 's>(
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
global_settings: &'g GlobalSettings<'g, 's>,
|
global_settings: &'g GlobalSettings<'g, 's>,
|
||||||
) -> Result<Document<'s>, String> {
|
) -> Result<Document<'s>, Box<dyn std::error::Error>> {
|
||||||
let initial_context = ContextElement::document_context();
|
let initial_context = ContextElement::document_context();
|
||||||
let initial_context = Context::new(global_settings, List::new(&initial_context));
|
let initial_context = Context::new(global_settings, List::new(&initial_context));
|
||||||
let wrapped_input = OrgSource::new(input);
|
let wrapped_input = OrgSource::new(input);
|
||||||
@ -49,7 +49,7 @@ pub fn parse_with_settings<'g, 's>(
|
|||||||
all_consuming(parser_with_context!(document_org_source)(&initial_context))(wrapped_input)
|
all_consuming(parser_with_context!(document_org_source)(&initial_context))(wrapped_input)
|
||||||
.map_err(|err| err.to_string())
|
.map_err(|err| err.to_string())
|
||||||
.map(|(_remaining, parsed_document)| parsed_document);
|
.map(|(_remaining, parsed_document)| parsed_document);
|
||||||
ret
|
Ok(ret?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a full org-mode document.
|
/// Parse a full org-mode document.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user