summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-06-27 23:35:02 +0200
committerAraq <rumpf_a@web.de>2015-06-29 02:48:31 +0200
commit2297a1aa6048fcbcffca4e2c2e4ede275261e83d (patch)
tree18366ccd56ca569fa892d0af5ac68b96ef4bbe52 /lib/pure
parentace9299a32d09bd25f9ccb8e8d77efca0185fb26 (diff)
downloadNim-2297a1aa6048fcbcffca4e2c2e4ede275261e83d.tar.gz
much better error message if an exe cannot be found
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/os.nim7
-rw-r--r--lib/pure/osproc.nim2
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index f29505590..6f8d923e3 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -261,7 +261,7 @@ proc osErrorMsg*(errorCode: OSErrorCode): string =
     if errorCode != OSErrorCode(0'i32):
       result = $os.strerror(errorCode.int32)
 
-proc raiseOSError*(errorCode: OSErrorCode) =
+proc raiseOSError*(errorCode: OSErrorCode; additionalInfo = "") {.noinline.} =
   ## Raises an ``OSError`` exception. The ``errorCode`` will determine the
   ## message, ``osErrorMsg`` will be used to get this message.
   ##
@@ -271,7 +271,10 @@ proc raiseOSError*(errorCode: OSErrorCode) =
   ## the message ``unknown OS error`` will be used.
   var e: ref OSError; new(e)
   e.errorCode = errorCode.int32
-  e.msg = osErrorMsg(errorCode)
+  if additionalInfo.len == 0:
+    e.msg = osErrorMsg(errorCode)
+  else:
+    e.msg = additionalInfo & " " & osErrorMsg(errorCode)
   if e.msg == "":
     e.msg = "unknown OS error"
   raise e
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 33f5419d5..add4bc0a8 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -468,7 +468,7 @@ when defined(Windows) and not defined(useNimRtl):
         fileClose(si.hStdError)
 
     if e != nil: dealloc(e)
-    if success == 0: raiseOSError(lastError)
+    if success == 0: raiseOSError(lastError, command)
     # Close the handle now so anyone waiting is woken:
     discard closeHandle(procInfo.hThread)
     result.fProcessHandle = procInfo.hProcess