addresses issue #8391 show runtime context on some failed operations (#8393)

This commit is contained in:
Timothee Cour
2018-07-23 13:58:03 -07:00
committed by Andreas Rumpf
parent 503dc22236
commit 9249276db0
2 changed files with 5 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ proc raiseOSError*(errorCode: OSErrorCode; additionalInfo = "") {.noinline.} =
if additionalInfo.len == 0:
e.msg = osErrorMsg(errorCode)
else:
e.msg = osErrorMsg(errorCode) & "\nAdditional info: " & additionalInfo
e.msg = osErrorMsg(errorCode) & "\nAdditional info: '" & additionalInfo & "'"
if e.msg == "":
e.msg = "unknown OS error"
raise e

View File

@@ -971,7 +971,7 @@ proc rawCreateDir(dir: string): bool =
elif errno in {EEXIST, ENOSYS}:
result = false
else:
raiseOSError(osLastError())
raiseOSError(osLastError(), dir)
elif defined(posix):
let res = mkdir(dir, 0o777)
if res == 0'i32:
@@ -980,7 +980,7 @@ proc rawCreateDir(dir: string): bool =
result = false
else:
#echo res
raiseOSError(osLastError())
raiseOSError(osLastError(), dir)
else:
when useWinUnicode:
wrapUnary(res, createDirectoryW, dir)
@@ -992,7 +992,7 @@ proc rawCreateDir(dir: string): bool =
elif getLastError() == 183'i32:
result = false
else:
raiseOSError(osLastError())
raiseOSError(osLastError(), dir)
proc existsOrCreateDir*(dir: string): bool {.rtl, extern: "nos$1",
tags: [WriteDirEffect, ReadDirEffect].} =
@@ -1005,7 +1005,7 @@ proc existsOrCreateDir*(dir: string): bool {.rtl, extern: "nos$1",
if result:
# path already exists - need to check that it is indeed a directory
if not existsDir(dir):
raise newException(IOError, "Failed to create the directory")
raise newException(IOError, "Failed to create '" & dir & "'")
proc createDir*(dir: string) {.rtl, extern: "nos$1",
tags: [WriteDirEffect, ReadDirEffect].} =