Tcl Source Code

View Ticket
Bounty program for improvements to Tcl and certain Tcl packages.
08:13 Ticket [800716ffff] publicize TclWinConvertError and TclWinConvertWSAError status still Open with 4 other changes artifact: 0a8d85cd2c user: davygrvy
07:18 Ticket [800716ffff]: 4 changes artifact: 11f5b82df8 user: davygrvy
07:07 Add attachment to ticket [800716ffff] artifact: 759343a11d user: davygrvy
07:07 Ticket [800716ffff] publicize TclWinConvertError and TclWinConvertWSAError status still Open with 4 other changes artifact: 838e13c824 user: davygrvy
07:05 Ticket [800716ffff]: 4 changes artifact: 8cf218dead user: davygrvy
21:58 Ticket [800716ffff]: 4 changes artifact: 8e59eb5a4c user: dgp
18:51 Ticket [800716ffff]: 4 changes artifact: b95a8ed2d0 user: davygrvy
17:35 Ticket [800716ffff]: 4 changes artifact: 2a69756dcc user: davygrvy
04:38 Ticket [800716ffff]: 4 changes artifact: 12b1ba2333 user: davygrvy
04:38 Add attachment patch.txt to ticket [800716ffff] artifact: 4a274eef40 user: davygrvy
21:37 New ticket [800716ffff] publicize TclWinConvertError and TclWinConvertWSAError. artifact: 2aca1d5917 user: davygrvy

Ticket UUID: 800716
Title: publicize TclWinConvertError and TclWinConvertWSAError
Type: Patch Version: None
Submitter: davygrvy Created on: 2003-09-04 21:37:59
Subsystem: 52. Portability Support Assigned To: stwo
Priority: 5 Medium Severity:
Status: Open Last Modified: 2003-09-10 08:13:24
Resolution: None Closed By:
    Closed on:
TclWinConvertError and TclWinConvertWSAError are 
private internal functions.  They could be very useful to 
extension authors.  I see a need for it.  Let's make them 

Also, TclWinConvertWSAError doesn't map to all WSAE* 
error codes.  Included are mappings to all of them.  
Unfortunetly, all the added can only return EINVAL until 
the posix codes they translate into get more meaningful 
to windows.  Effectively, the behavior is still unchanged.


WSA_QOS_POLICY_FAILURE,  'rejected for administrative 
reasons - bad credentials'
WSAEPROVIDERFAILEDINIT, 'The requested service 
provider could not be loaded or initialized'

What posix codes do those get?  Some detective work 
needs to be done with these.  I really don't have a clue.

The main reason I want to enlargen the mappings is to 
include WSAHOST_NOT_FOUND.  I hate that the 
[socket] command can only return 'invalid argument' 
instead of 'authoritative host not found' or 'try again', 
or ....

Should this really be a TIP?
User Comments: davygrvy added on 2003-09-10 08:13:24:
Logged In: YES 

Here's some code that shows how an extension could make 
use of this feature:

CONST char *
ExpWinExpError TCL_VARARGS_DEF(Tcl_Interp *, arg1)
    CONST char *id, *msg;
    va_list argList;
    Tcl_Interp *interp;
    DWORD err = GetLastError();

    interp = TCL_VARARGS_START(Tcl_Interp *, arg1, argList);

     * If the "customer" bit is set, this error is ours. else 
     * it to the system.

    if (errorCode & (0x1 << 29)) {
id = ExpWinExpErrId(err);
msg = ExpWinExpErrMsgVA(err, argList);
Tcl_SetErrorCode(interp, "EXPECT", id, msg, 0L);
    } else {
id = Tcl_Win32ErrId(err);
msg = Tcl_Win32ErrMsgVA(err, argList);
Tcl_SetErrorCode(interp, "WIN32", id, msg, 0L);
    return msg;

davygrvy added on 2003-09-10 07:18:50:
Logged In: YES 

Code could be added so that if Tcl(_)WinConvertError can't 
make the translation, the native message could be used 

But Tcl is supposed to the great equilizer, and this new 
concept might be foriegn as it attemps to break from 'least 
common denominator' hole and might not be helpful for the 
places that are to provide a generic interface.

In places where the native message is desirable, the ability to 
get it, is now easy.

davygrvy added on 2003-09-10 07:07:42:
File Added - 61125:

davygrvy added on 2003-09-10 07:05:07:
Logged In: YES 

Here's another patch that adds Tcl_Win32Error(), 
Tcl_Win32ErrId(), Tcl_Win32ErrMsg(), and Tcl_Win32ErrMsgVA

The concept of setting errno and returning from a function is 
usually then displayed to the user with Tcl_PosixError() in a 
generic layer for setting $errorCode.  Tcl_Win32Error() is 
exactly analogous to that, except that it gets the error code 
from GetLastError() for the exact windows error.

I would use this from an extension!  See the shift?  Instead of 
returning from a function with errno set, give the function the 
interp and let it set $errorCode itself.  This concept is working 
well in a project I'm doing.  NOTHING is getting lost in a 
translation as there aren't any to be made!

Tcl_Win32ErrId() is 100% complete and match the october 
2002 release of the platform SDK.  Error messages are asked 
for from the system with FormatMessage and could support 

win/tclWinError.c builds with stock VC5, VC6, and with the 
platform SDK headers, too.

my wrists are sore.. where's an ice pack in this house?

dgp added on 2003-09-05 21:58:23:
Logged In: YES 

Localized error messages are
 still a good idea, just one that needs
to wait for a more thorough use of
::errorCode for script processing.
jenglish and kbk both have ideas
on this, but over a fairly extended
time frame.

davygrvy added on 2003-09-05 18:51:57:
Logged In: YES 

Please ignore that last post.  That would break ALL scripts 
that did matching on error messages ;)

davygrvy added on 2003-09-05 17:35:46:
Logged In: YES 

It would be nice also, if Tcl_ErrnoMsg() returned localized 

davygrvy added on 2003-09-05 04:38:00:
File Added - 60637: patch.txt