summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-03-23 12:58:38 (GMT)
committernijtmans <nijtmans>2010-03-23 12:58:38 (GMT)
commitddc540e0328b146dd871015f3c32296da797920a (patch)
treeaff7dbfe0bd97a4d49dca1356f58e5452e89f3a8 /generic
parent6838a5c3396760aa126ef99f25c1bb7b992700ba (diff)
downloadtcl-ddc540e0328b146dd871015f3c32296da797920a.zip
tcl-ddc540e0328b146dd871015f3c32296da797920a.tar.gz
tcl-ddc540e0328b146dd871015f3c32296da797920a.tar.bz2
Make error message in "try" implementation
exactly the same as the one in "return"
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c18
-rw-r--r--generic/tclCompCmdsSZ.c6
2 files changed, 13 insertions, 11 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index ebfd7e7..3f1618d 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.206 2010/03/22 22:47:03 dgp Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.207 2010/03/23 12:58:38 nijtmans Exp $
*/
#include "tclInt.h"
@@ -4159,13 +4159,13 @@ TclNRTryObjCmd(
{
Tcl_Obj *bodyObj, *handlersObj, *finallyObj = NULL;
int i, bodyShared, haveHandlers, dummy, code;
- static const char *handlerNames[] = {
+ static const char *const handlerNames[] = {
"finally", "on", "trap", NULL
};
enum Handlers {
TryFinally, TryOn, TryTrap
};
- static const char *exceptionNames[] = {
+ static const char *const returnCodes[] = {
"ok", "error", "return", "break", "continue", NULL
};
@@ -4218,12 +4218,14 @@ TclNRTryObjCmd(
return TCL_ERROR;
}
if (Tcl_GetIntFromObj(NULL, objv[i+1], &code) != TCL_OK
- && Tcl_GetIndexFromObj(NULL, objv[i+1], exceptionNames,
+ && Tcl_GetIndexFromObj(NULL, objv[i+1], returnCodes,
"code", 0, &code) != TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad code '%s': must be integer, \"ok\", \"error\", "
- "\"return\", \"break\" or \"continue\"",
- Tcl_GetString(objv[i+1])));
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "bad completion code \"",
+ TclGetString(objv[i+1]),
+ "\": must be ok, error, return, break, "
+ "continue, or an integer", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "RESULT", "ILLEGAL_CODE", NULL);
Tcl_DecrRefCount(handlersObj);
return TCL_ERROR;
}
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index f6f8efb..d8fdcd1 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompCmdsSZ.c,v 1.5 2010/03/19 11:54:07 dkf Exp $
+ * RCS: @(#) $Id: tclCompCmdsSZ.c,v 1.6 2010/03/23 12:58:39 nijtmans Exp $
*/
#include "tclInt.h"
@@ -1992,7 +1992,7 @@ TclCompileTryCmd(
} else if (tokenPtr[1].size == 2
&& !strncmp(tokenPtr[1].start, "on", 2)) {
int code;
- static const char *codes[] = {
+ static const char *const returnCodes[] = {
"ok", "error", "return", "break", "continue", NULL
};
@@ -2008,7 +2008,7 @@ TclCompileTryCmd(
goto failedToCompile;
}
if (Tcl_GetIntFromObj(NULL, tmpObj, &code) != TCL_OK
- && Tcl_GetIndexFromObj(NULL, tmpObj, codes, "",
+ && Tcl_GetIndexFromObj(NULL, tmpObj, returnCodes, "",
TCL_EXACT, &code) != TCL_OK) {
TclDecrRefCount(tmpObj);
goto failedToCompile;