Skip to content

Commit

Permalink
addresses issue nim-lang#8391 show runtime context on some failed ope…
Browse files Browse the repository at this point in the history
…rations (nim-lang#8393)
  • Loading branch information
timotheecour committed Jul 23, 2018
1 parent d41ffa0 commit b03a448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/pure/includes/oserr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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].} =
Expand All @@ -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].} =
Expand Down

0 comments on commit b03a448

Please sign in to comment.