Unify some more error handling.

This commit is contained in:
Tom Alexander
2023-10-17 12:22:52 -04:00
parent d20b4a410b
commit 6139ea328d
2 changed files with 18 additions and 14 deletions

View File

@@ -134,7 +134,7 @@ fn document_org_source<'b, 'g, 'r, 's>(
}
final_settings.extend(document_settings);
let new_settings = apply_in_buffer_settings(final_settings, context.get_global_settings())
.map_err(|err| nom::Err::Error(CustomError::from(err)))?;
.map_err(nom::Err::Error)?;
let new_context = context.with_global_settings(&new_settings);
let context = &new_context;
@@ -159,15 +159,13 @@ fn document_org_source<'b, 'g, 'r, 's>(
let parser_context = context.with_global_settings(&new_global_settings);
let (remaining, mut document) = _document(&parser_context, input)
.map(|(rem, out)| (Into::<&str>::into(rem), out))?;
apply_post_parse_in_buffer_settings(&mut document)
.map_err(|err| nom::Err::<CustomError>::Failure(err.into()))?;
apply_post_parse_in_buffer_settings(&mut document);
return Ok((remaining.into(), document));
}
}
// Find final in-buffer settings that do not impact parsing
apply_post_parse_in_buffer_settings(&mut document)
.map_err(|err| nom::Err::<CustomError>::Failure(err.into()))?;
apply_post_parse_in_buffer_settings(&mut document);
Ok((remaining.into(), document))
}