Skip to content

Commit

Permalink
Merge pull request #20 from hugoduncan/expose-template-error
Browse files Browse the repository at this point in the history
Make TemplateError accessible
  • Loading branch information
sunng87 committed Apr 16, 2015
2 parents dae2e31 + 4da884a commit 8668eaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ extern crate log;
extern crate rustc_serialize as serialize;
extern crate regex;

pub use self::template::{Template, Helper};
pub use self::template::{Template, TemplateError, Helper};
pub use self::registry::Registry as Handlebars;
pub use self::render::{Renderable, RenderError, RenderContext};
pub use self::helpers::{HelperDef};
Expand Down
13 changes: 13 additions & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::cmp::min;
use std::ops::BitOr;
use std::num::FromPrimitive;
use std::error;
use std::fmt::{self, Debug, Formatter};
use std::collections::{BTreeMap, VecDeque};
use std::string::ToString;
Expand Down Expand Up @@ -111,6 +112,18 @@ impl ToString for Helper {
#[derive(Debug, Clone, Copy)]
pub struct TemplateError;

impl fmt::Display for TemplateError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "TemplateError")
}
}

impl error::Error for TemplateError {
fn description(&self) -> &str {
"Template error"
}
}

impl Helper {
fn parse(source: String, block: bool) -> Result<Helper, TemplateError> {
let mut tokens = source.split(|c: char| c.is_whitespace())
Expand Down

0 comments on commit 8668eaf

Please sign in to comment.