Skip to content

Errors from render_template have themselves as source #398

Closed
@SuperCuber

Description

@SuperCuber

Code:

extern crate handlebars;

fn main() {
    let handlebars = handlebars::Handlebars::new();
    let e = handlebars.render_template("{{ whoops", &std::collections::BTreeMap::<String, String>::new()).unwrap_err();
    let e: Box<dyn std::error::Error> = Box::new(e);
    println!("{}", e);
    println!("{}", e.source().unwrap());
    println!("{:?}", e.source().unwrap().source());
}

Expected output:

Template error: invalid handlebars syntax.
    --> Template error in "Unnamed template":1:10
     |
   0 | {{ whoops
     |---------
     |
     = reason: invalid handlebars syntax.

<panic because no source>

Actual output:

Template error: invalid handlebars syntax.
    --> Template error in "Unnamed template":1:10
     |
   0 | {{ whoops
     |---------
     |
     = reason: invalid handlebars syntax.

Template error: invalid handlebars syntax.
    --> Template error in "Unnamed template":1:10
     |
   0 | {{ whoops
     |---------
     |
     = reason: invalid handlebars syntax.

None

I haven't tested, but this could also be the case for other functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions