Change public interface to return boxed dynamic error instead of String.
All checks were successful
rustfmt Build rustfmt has succeeded
rust-test Build rust-test has succeeded
rust-build Build rust-build has succeeded
rust-foreign-document-test Build rust-foreign-document-test has succeeded

This commit is contained in:
Tom Alexander 2023-09-12 15:52:01 -04:00
parent 37e85158ea
commit e4c0e32536
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -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.
#[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())
}
@ -41,7 +41,7 @@ pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
pub fn parse_with_settings<'g, 's>(
input: &'s str,
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 = Context::new(global_settings, List::new(&initial_context));
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)
.map_err(|err| err.to_string())
.map(|(_remaining, parsed_document)| parsed_document);
ret
Ok(ret?)
}
/// Parse a full org-mode document.