oserrors
nimony/lib/std/oserrors.nim
type OSErrorCode = distinct int32Specifies an OS Error Code.
func raiseOSError(errorCode: OSErrorCode; additionalInfo: string)Raises an OSError exception.
Read the description of the
newOSError proc_ to learn how the exception object is created.A zero
errorCodemaps toSuccess, and raising that is a no-op — this proc would return, in breach of.noreturn, into a caller that has already established the operation failed. It then carries on with whatever the failed call left behind. That is not hypothetical:errnoreads zero whenever the error slot was never written for this call (a raw-syscall wrapper, or libc's errno read through the wrong accessor), and the result was a-1file descriptor travelling intommapand aMAP_FAILEDring being written through. The caller knows something went wrong; report that rather than nothing.proc osLastError(): OSErrorCodeRetrieves the last operating system error code.
This procedure is useful in the event when an OS call fails. In that case this procedure will return the error code describing the reason why the OS call failed. The
OSErrorMsgprocedure can then be used to convert this code into a string... warning:: The behaviour of this procedure varies between Windows and POSIX systems. On Windows some OS calls can reset the error code to
0causing this procedure to return0. It is therefore advised to call this procedure immediately after an OS call fails. On POSIX systems this is not a problem.See also:
osErrorMsg proc_raiseOSError proc_