From 2c64dbd87a261d35a6a0cb1868bc2e7aef1a9073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Arzel?= Date: Thu, 4 Aug 2016 14:57:45 +0200 Subject: [PATCH] Adding Missing_section exception --- lib/mustache.ml | 2 +- lib/mustache.mli | 1 + lib/mustache_types.ml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mustache.ml b/lib/mustache.ml index 5eaa4d1..634ecc1 100644 --- a/lib/mustache.ml +++ b/lib/mustache.ml @@ -160,7 +160,7 @@ module Lookup = struct | (`A _ | `O _) as js -> js | _ -> js with Not_found -> - if strict then raise Not_found else `Bool false + if strict then raise (Missing_section key) else `Bool false let inverted (js : Json.value) ~key = match js with diff --git a/lib/mustache.mli b/lib/mustache.mli index 95c990d..453a6fd 100644 --- a/lib/mustache.mli +++ b/lib/mustache.mli @@ -4,6 +4,7 @@ exception Invalid_template of string (** Raised when a missing variable in a template is not substituted *) exception Missing_variable of string +exception Missing_section of string module Json : sig (** Compatible with Ezjsonm *) type value = diff --git a/lib/mustache_types.ml b/lib/mustache_types.ml index 16f9362..2a0fbf7 100644 --- a/lib/mustache_types.ml +++ b/lib/mustache_types.ml @@ -36,3 +36,4 @@ and section = { exception Invalid_param of string exception Invalid_template of string exception Missing_variable of string +exception Missing_section of string