Skip to content

Commit

Permalink
jansson: add path to error log for easier debugging
Browse files Browse the repository at this point in the history
(cherry picked from commit 918cde9)
  • Loading branch information
kelchy authored and miconda committed Jun 13, 2017
1 parent c1f042d commit 06dc78f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions modules/jansson/jansson_funcs.c
Expand Up @@ -142,47 +142,47 @@ int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in,
if(STR_EQ_STATIC(type_s, "object") || STR_EQ_STATIC(type_s, "obj")){
value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
if(value && !json_is_object(value)) {
ERR("value to add is not an object\n");
ERR("value to add is not an object - \"%s\"\n", path_s.s);
goto fail;
}

}else if(STR_EQ_STATIC(type_s, "array")) {
value = json_loads(value_s.s, JSON_REJECT_DUPLICATES, &parsing_error);
if(value && !json_is_array(value)) {
ERR("value to add is not an array\n");
ERR("value to add is not an array - \"%s\"\n", path_s.s);
goto fail;
}

}else if(STR_EQ_STATIC(type_s, "string")
|| STR_EQ_STATIC(type_s, "str")) {
value = json_string(value_s.s);
if(!value || !json_is_string(value)) {
ERR("value to add is not a string\n");
ERR("value to add is not a string - \"%s\"\n", path_s.s);
goto fail;
}

}else if(STR_EQ_STATIC(type_s, "integer")
|| STR_EQ_STATIC(type_s, "int")) {
long long i = strtoll(value_s.s, &endptr, 10);
if(*endptr != '\0') {
ERR("parsing int failed for \"%s\"\n", value_s.s);
ERR("parsing int failed for \"%s\" - \"%s\"\n", path_s.s, value_s.s);
goto fail;
}
value = json_integer(i);
if(!value || !json_is_integer(value)) {
ERR("value to add is not an integer\n");
ERR("value to add is not an integer \"%s\"\n", path_s.s);
goto fail;
}

}else if(STR_EQ_STATIC(type_s, "real")) {
double d = strtod(value_s.s, &endptr);
if(*endptr != '\0') {
ERR("parsing real failed for \"%s\"\n", value_s.s);
ERR("parsing real failed for \"%s\" - \"%s\"\n", path_s.s, value_s.s);
goto fail;
}
value = json_real(d);
if(!value || !json_is_real(value)) {
ERR("value to add is not a real\n");
ERR("value to add is not a real \"%s\"\n", path_s.s);
goto fail;
}

Expand Down

0 comments on commit 06dc78f

Please sign in to comment.