]> wagner.pp.ru Git - sites/home_page.git/blob - software/tcl/tcom_error_msg.diff
grandpa picture
[sites/home_page.git] / software / tcl / tcom_error_msg.diff
1 --- tcom/src/refCmd.cpp.orig    2003-11-06 18:29:01.000000000 +0300
2 +++ tcom/src/refCmd.cpp 2005-12-22 15:07:36.000000000 +0300
3 @@ -61,13 +61,32 @@
4  \r
5      // Append description.\r
6      const wchar_t *pWide = static_cast<const wchar_t *>(description);\r
7 +\r
8      if (pWide == 0) {\r
9 -        pWide = L"Unknown error";\r
10 -    }\r
11 +        wchar_t *buffer;
12 +               bool freebuf=true;
13 +               FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|
14 +                       FORMAT_MESSAGE_FROM_SYSTEM,
15 +                       NULL,
16 +                       hresult,
17 +                       MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
18 +                       (LPWSTR) &buffer,
19 +                       0,NULL);\r
20 +               if (buffer == 0) {\r
21 +                 buffer = L"Unknown error";\r
22 +                 freebuf=false;\r
23 +               }\r
24 +               TclObject descriptionObj(buffer);\r
25 +               errorCode.lappend(descriptionObj);\r
26 +               result=descriptionObj;\r
27 +               if (freebuf) {\r
28 +                       LocalFree(buffer);\r
29 +               }\r
30 +       } else {\r
31      TclObject descriptionObj(pWide);\r
32      errorCode.lappend(descriptionObj);\r
33      result.lappend(descriptionObj);\r
34 -\r
35 +       }\r
36  #ifndef NDEBUG\r
37      // Append file and line number.\r
38      std::ostringstream fileLine;\r