aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-06-12 19:02:12 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-06-12 19:43:31 +0200
commited2743714bec59de1273cc0617d6b588a06a1203 (patch)
treed3c1dbf24bc766011b7361039a6eb72e0aaa3034
parent51c7935c6535ddb5865e6bd67de603326458cedd (diff)
Fix lack of error message on mustach issue
Change-Id: I16139c133d7031e38f4c63ff6369f1d7478fc86f Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/wgtpkg-mustach.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/wgtpkg-mustach.c b/src/wgtpkg-mustach.c
index 110f11b..45d94e8 100644
--- a/src/wgtpkg-mustach.c
+++ b/src/wgtpkg-mustach.c
@@ -21,10 +21,12 @@
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <json-c/json.h>
#include "mustach.h"
+#include "verbose.h"
#define MAX_DEPTH 256
@@ -321,8 +323,29 @@ static struct mustach_itf itf = {
*/
int apply_mustach(const char *template, struct json_object *root, char **result, size_t *size)
{
+ int rc;
struct expl e;
+
e.root = root;
- return mustach(template, &itf, &e, result, size);
+ rc = mustach(template, &itf, &e, result, size);
+ if (rc < 0) {
+ static const char *msgs[] = {
+ "SYSTEM",
+ "UNEXPECTED_END",
+ "EMPTY_TAG",
+ "TAG_TOO_LONG",
+ "BAD_SEPARATORS",
+ "TOO_DEPTH",
+ "CLOSING",
+ "BAD_UNESCAPE_TAG"
+ };
+
+ rc = -(rc + 1);
+ ERROR("mustach error found: MUSTACH_ERROR_%s",
+ rc < 0 || rc >= (int)(sizeof msgs / sizeof * msgs) ? "???" : msgs[rc]);
+ rc = -1;
+ errno = EINVAL;
+ }
+ return rc;
}