diff options
author | nijtmans <nijtmans> | 2010-03-23 12:58:38 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-03-23 12:58:38 (GMT) |
commit | ddc540e0328b146dd871015f3c32296da797920a (patch) | |
tree | aff7dbfe0bd97a4d49dca1356f58e5452e89f3a8 /generic/tclCmdMZ.c | |
parent | 6838a5c3396760aa126ef99f25c1bb7b992700ba (diff) | |
download | tcl-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/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 18 |
1 files changed, 10 insertions, 8 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; } |