Change-Id: I16139c133d7031e38f4c63ff6369f1d7478fc86f
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <json-c/json.h>
#include "mustach.h"
#include <json-c/json.h>
#include "mustach.h"
*/
int apply_mustach(const char *template, struct json_object *root, char **result, size_t *size)
{
*/
int apply_mustach(const char *template, struct json_object *root, char **result, size_t *size)
{
- 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;