From 0f7672c25e0e55fd641ffe702fb4b06716914912 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 3 Jan 2020 13:02:57 -0600 Subject: [PATCH] Revert "windows.errors: streamline error handling and throwing" This reverts commit ca474dd154c8ce59b4a1e40281a4b9fc6e182a1a. --- basis/windows/errors/authors.txt | 1 - basis/windows/errors/errors.factor | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/basis/windows/errors/authors.txt b/basis/windows/errors/authors.txt index d652f68ac8..7c1b2f2279 100644 --- a/basis/windows/errors/authors.txt +++ b/basis/windows/errors/authors.txt @@ -1,2 +1 @@ Doug Coleman -Alexander Ilin diff --git a/basis/windows/errors/errors.factor b/basis/windows/errors/errors.factor index ffb735be08..f5e5314e2f 100644 --- a/basis/windows/errors/errors.factor +++ b/basis/windows/errors/errors.factor @@ -719,18 +719,23 @@ CONSTANT: FORMAT_MESSAGE_MAX_WIDTH_MASK 0x000000FF ERROR: windows-error n string ; -: throw-windows-error ( n -- * ) - dup n>win32-error-string windows-error ; +: (win32-error) ( n -- ) + [ dup win32-error-string windows-error ] unless-zero ; -: n>win32-error-check ( n -- ) - [ throw-windows-error ] unless-zero ; +: win32-error ( -- ) + 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 ( 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 ) dup INVALID_HANDLE_VALUE = [ win32-error ] when ; -- 2.34.1