]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/errors/errors.factor
windows.errors, debugger.windows: improve description of Windows error objects
[factor.git] / basis / windows / errors / errors.factor
index a3dbaf40ffc0975d826a2a2dc7fd4f882c8a6e2b..a4943ef87727ee7020dd0c6e33270d24cf9a7030 100755 (executable)
@@ -1,7 +1,8 @@
 USING: alien.data kernel locals math math.bitwise
 windows.kernel32 sequences byte-arrays unicode.categories
 io.encodings.string io.encodings.utf16n alien.strings
-arrays literals windows.types specialized-arrays ;
+arrays literals windows.types specialized-arrays
+math.parser ;
 SPECIALIZED-ARRAY: TCHAR
 IN: windows.errors
 
@@ -703,7 +704,6 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK   HEX: 000000FF
 : make-lang-id ( lang1 lang2 -- n )
     10 shift bitor ; inline
 
-ERROR: error-message-failed id ;
 :: n>win32-error-string ( id -- string )
     flags{
         FORMAT_MESSAGE_FROM_SYSTEM
@@ -713,8 +713,10 @@ ERROR: error-message-failed id ;
     id
     LANG_NEUTRAL SUBLANG_DEFAULT make-lang-id
     32768 [ TCHAR <c-array> ] [ ] bi
-    f pick [ FormatMessage 0 = [ id error-message-failed ] when ] dip
-    utf16n alien>string [ blank? ] trim ;
+    f pick [ FormatMessage ] dip
+    swap zero?
+    [ drop "Unknown error 0x" id HEX: ffff,ffff bitand >hex append ]
+    [ utf16n alien>string [ blank? ] trim ] if ;
 
 : win32-error-string ( -- str )
     GetLastError n>win32-error-string ;