mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Fix OSError errorCode field is not assigned a value (#22954)
In this PR, the following changes were made: 1. Replaced `raise newException(OSError, osErrorMsg(errno))` in batches with `raiseOSError(errcode)`. 2. Replaced `newException(OSError, osErrorMsg(errno))` in batches with `newOSError(errcode)`. There are still some places that have not been replaced. After checking, they are not system errors in the traditional sense. ```nim proc dlclose(lib: LibHandle) = raise newException(OSError, "dlclose not implemented on Nintendo Switch!") ``` ```nim if not fileExists(result) and not dirExists(result): # consider using: `raiseOSError(osLastError(), result)` raise newException(OSError, "file '" & result & "' does not exist") ``` ```nim proc paramStr*(i: int): string = raise newException(OSError, "paramStr is not implemented on Genode") ```
This commit is contained in:
@@ -19,7 +19,7 @@ when defined(windows):
|
||||
retFuture.complete()
|
||||
return true
|
||||
else:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(OSErrorCode(ret))))
|
||||
retFuture.fail(newOSError(OSErrorCode(ret)))
|
||||
return true
|
||||
|
||||
var aiList = getAddrInfo(address, port, domain)
|
||||
@@ -45,7 +45,7 @@ when defined(windows):
|
||||
|
||||
freeAddrInfo(aiList)
|
||||
if not success:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
retFuture.fail(newOSError(lastError))
|
||||
return retFuture
|
||||
|
||||
proc winRecv*(socket: AsyncFD, size: int,
|
||||
@@ -63,7 +63,7 @@ when defined(windows):
|
||||
if flags.isDisconnectionError(lastError):
|
||||
retFuture.complete("")
|
||||
else:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
retFuture.fail(newOSError(lastError))
|
||||
elif res == 0:
|
||||
# Disconnected
|
||||
retFuture.complete("")
|
||||
@@ -88,7 +88,7 @@ when defined(windows):
|
||||
if flags.isDisconnectionError(lastError):
|
||||
retFuture.complete(0)
|
||||
else:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
retFuture.fail(newOSError(lastError))
|
||||
else:
|
||||
retFuture.complete(res)
|
||||
# TODO: The following causes a massive slowdown.
|
||||
@@ -112,7 +112,7 @@ when defined(windows):
|
||||
if flags.isDisconnectionError(lastError):
|
||||
retFuture.complete()
|
||||
else:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
retFuture.fail(newOSError(lastError))
|
||||
else:
|
||||
written.inc(res)
|
||||
if res != netSize:
|
||||
@@ -136,7 +136,7 @@ when defined(windows):
|
||||
var client = nativesockets.accept(sock.SocketHandle,
|
||||
cast[ptr SockAddr](addr(sockAddress)), addr(addrLen))
|
||||
if client == osInvalidSocket:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(osLastError())))
|
||||
retFuture.fail(newOSError(osLastError()))
|
||||
else:
|
||||
retFuture.complete((getAddrString(cast[ptr SockAddr](addr sockAddress)), client.AsyncFD))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user