Revert "windows.errors: streamline error handling and throwing"

This reverts commit ca474dd154.
modern-harvey3
Doug Coleman 2019-12-05 09:21:24 -06:00
parent cb8499373d
commit 8dd5fdda0f
2 changed files with 12 additions and 8 deletions

View File

@ -1,2 +1 @@
Doug Coleman Doug Coleman
Alexander Ilin

View File

@ -719,18 +719,23 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF
ERROR: windows-error n string ; ERROR: windows-error n string ;
: throw-windows-error ( n -- * ) : (win32-error) ( n -- )
dup n>win32-error-string windows-error ; [ dup win32-error-string windows-error ] unless-zero ;
: n>win32-error-check ( n -- ) : win32-error ( -- )
[ throw-windows-error ] unless-zero ; GetLastError (win32-error) ;
! Note that win32-error* words throw GetLastError code.
: win32-error ( -- ) GetLastError n>win32-error-check ;
: win32-error=0/f ( n -- ) { 0 f } member? [ win32-error ] when ; : win32-error=0/f ( n -- ) { 0 f } member? [ win32-error ] when ;
: win32-error>0 ( n -- ) 0 > [ win32-error ] when ; : win32-error>0 ( n -- ) 0 > [ win32-error ] when ;
: win32-error<0 ( n -- ) 0 < [ win32-error ] when ; : win32-error<0 ( n -- ) 0 < [ win32-error ] when ;
: win32-error<>0 ( n -- ) [ win32-error ] unless-zero ; : win32-error<>0 ( n -- ) zero? [ win32-error ] unless ;
: n>win32-error-check ( n -- )
dup ERROR_SUCCESS = [
drop
] [
dup n>win32-error-string windows-error
] if ;
: check-invalid-handle ( handle -- handle ) : check-invalid-handle ( handle -- handle )
dup INVALID_HANDLE_VALUE = [ win32-error ] when ; dup INVALID_HANDLE_VALUE = [ win32-error ] when ;