summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-29 21:42:18 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-29 21:42:18 (GMT)
commit9f0f499ce4ff957b12e92c788da5e3d9af205a11 (patch)
tree8d9204fce9d09230622a141a301e1ef225fb8784 /generic/tclListObj.c
parent90a61e5336000d17a67fb2af6b6b896266bd91e4 (diff)
downloadtcl-9f0f499ce4ff957b12e92c788da5e3d9af205a11.zip
tcl-9f0f499ce4ff957b12e92c788da5e3d9af205a11.tar.gz
tcl-9f0f499ce4ff957b12e92c788da5e3d9af205a11.tar.bz2
Better error-message in case of "index out of range", mentioning the actual index which was out of range. Also, use the same error-code, because the underlying cause is all the same.
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index bae6452..5de2eac 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -1608,11 +1608,10 @@ TclLsetFlat(
|| (valuePtr == NULL && index >= elemCount)) {
/* ...the index points outside the sublist. */
if (interp != NULL) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("list index out of range", -1));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION",
- valuePtr == NULL ? "LPOP" : "LSET",
- "BADINDEX", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "index \"%s\" out of range", Tcl_GetString(indexArray[-1])));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
+ "OUTOFRANGE", NULL);
}
result = TCL_ERROR;
break;
@@ -1803,10 +1802,10 @@ TclListObjSetElement(
(void) Tcl_GetStringFromObj(listPtr, &length);
if (length == 0) {
if (interp != NULL) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("list index out of range", -1));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSET",
- "BADINDEX", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "index \"%d\" out of range", index));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX",
+ "OUTOFRANGE", NULL);
}
return TCL_ERROR;
}
@@ -1825,10 +1824,10 @@ TclListObjSetElement(
if (index<0 || index>=elemCount) {
if (interp != NULL) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("list index out of range", -1));
- Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSET", "BADINDEX",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "index \"%d\" out of range", index));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX",
+ "OUTOFRANGE", NULL);
}
return TCL_ERROR;
}