Skip to content

Commit

Permalink
Try to detect stack overflows and fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Oct 18, 2020
1 parent 5f16ac9 commit 2c85346
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions components/compiler/src/compile.rs
Expand Up @@ -59,6 +59,9 @@ where
let mut errs: Vec<Error> = Vec::new();
rx.iter().for_each(|(p, r)| {
if r.is_err() {
//if fail_fast {
//panic!(r.err());
//}
errs.push(r.err().unwrap());
} else {
let res = r.unwrap();
Expand Down
18 changes: 10 additions & 8 deletions components/compiler/src/hbs/helpers/document.rs
Expand Up @@ -80,15 +80,17 @@ impl HelperDef for Block {
rc: &mut RenderContext<'reg, 'rc>,
out: &mut dyn Output,
) -> HelperResult {

let template_path = rc.evaluate(ctx, "@root/file.template")?
.as_json()
.as_str()
.ok_or_else(|| {
RenderError::new(
"Type error for `file.template`, string expected",
)
})?
.to_string();
.as_json()
.as_str()
.ok_or_else(|| {
RenderError::new(
"Type error for `file.template`, string expected",
)
})?
.to_string();

super::render_document(
&template_path, &self.context, h, r, ctx, rc, out)
}
Expand Down
1 change: 1 addition & 0 deletions components/compiler/src/hbs/helpers/mod.rs
Expand Up @@ -49,6 +49,7 @@ fn get_front_matter_config(file: &PathBuf) -> frontmatter::Config {
frontmatter::Config::new_markdown(false)
}


fn render_document<'reg: 'rc, 'rc>(
template_path: &str,
context: &BuildContext,
Expand Down

0 comments on commit 2c85346

Please sign in to comment.