summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-19 22:38:59 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-19 22:38:59 +0200
commita09195f29ee8cd88411152cf311f4e4ab2f3b4b3 (patch)
treea090e2a0b77bcffba6afd178d49155c0ae8d6904 /src/json.c
parent74c69636563310d1e941fec695ff2d74518fe743 (diff)
downloadvim-git-a09195f29ee8cd88411152cf311f4e4ab2f3b4b3.tar.gz
patch 8.2.0800: errors from failing test are unclearv8.2.0800
Problem: Errors from failing test are unclear. Solution: Include text where parsing failed.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/json.c b/src/json.c
index ec3355e71..2720abfca 100644
--- a/src/json.c
+++ b/src/json.c
@@ -20,6 +20,8 @@
static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options);
+static char e_json_error[] = N_("E491: json decode error at '%s'");
+
/*
* Encode "val" into a JSON format string.
* The result is added to "gap"
@@ -740,7 +742,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
retval = json_decode_string(reader, cur_item, *p);
else
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
}
break;
@@ -748,7 +750,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
case ',': // comma: empty item
if ((options & JSON_JS) == 0)
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
break;
}
@@ -778,7 +780,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
}
if (!VIM_ISDIGIT(*sp))
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
break;
}
@@ -809,7 +811,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
&nr, NULL, 0, TRUE);
if (len == 0)
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
goto theend;
}
@@ -962,7 +964,7 @@ item_end:
retval = MAYBE;
else
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
@@ -980,7 +982,7 @@ item_end:
retval = MAYBE;
else
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
@@ -1036,7 +1038,7 @@ item_end:
retval = MAYBE;
else
{
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
@@ -1055,7 +1057,7 @@ item_end:
res->v_type = VAR_SPECIAL;
res->vval.v_number = VVAL_NONE;
}
- emsg(_(e_invarg));
+ semsg(_(e_json_error), p);
theend:
ga_clear(&stack);
@@ -1079,7 +1081,7 @@ json_decode_all(js_read_T *reader, typval_T *res, int options)
if (ret != OK)
{
if (ret == MAYBE)
- emsg(_(e_invarg));
+ semsg(_(e_json_error), reader->js_buf);
return FAIL;
}
json_skip_white(reader);