diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-11-21 11:22:01 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-11-21 11:22:01 (GMT) |
commit | 98ce25af617901be6af682a617c9b35abee2c548 (patch) | |
tree | 9e0af9c0fbcad14daf8bc95ee68ad11889e66f55 | |
parent | acc567c30fad3492d34aba6035b858e9c72db07c (diff) | |
download | tcl-98ce25af617901be6af682a617c9b35abee2c548.zip tcl-98ce25af617901be6af682a617c9b35abee2c548.tar.gz tcl-98ce25af617901be6af682a617c9b35abee2c548.tar.bz2 |
A little more errorCode goodness
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclPkg.c | 14 |
2 files changed, 15 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2007-10-21 Donal K. Fellows <donal.k.fellows@manchester.ac.uk> + + * generic/various: Start to return more useful Error codes, currently + mainly on assorted lookup failures. + 2007-11-20 Donal K. Fellows <dkf@users.sf.net> * generic/tclDictObj.c: Changed the underlying implementation of the diff --git a/generic/tclPkg.c b/generic/tclPkg.c index abc0070..8431eca 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclPkg.c,v 1.32 2007/11/18 22:30:10 dkf Exp $ + * RCS: @(#) $Id: tclPkg.c,v 1.33 2007/11/21 11:22:01 dkf Exp $ * * TIP #268. * Heavily rewritten to handle the extend version numbers, and extended @@ -690,15 +690,20 @@ Tcl_PkgPresentEx( if (hPtr) { pkgPtr = Tcl_GetHashValue(hPtr); if (pkgPtr->version != NULL) { - /* * At this point we know that the package is present. Make sure * that the provided version meets the current requirement by * calling Tcl_PkgRequireEx() to check for us. */ - return Tcl_PkgRequireEx(interp, name, version, exact, - clientDataPtr); + const char *foundVersion = Tcl_PkgRequireEx(interp, name, version, + exact, clientDataPtr); + + if (foundVersion == NULL) { + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "PACKAGE", name, + NULL); + } + return foundVersion; } } @@ -708,6 +713,7 @@ Tcl_PkgPresentEx( } else { Tcl_AppendResult(interp, "package ", name, " is not present", NULL); } + Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "PACKAGE", name, NULL); return NULL; } |