summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2014-03-11 23:06:22 +0000
committerDominik Picheta <dominikpicheta@googlemail.com>2014-03-11 23:06:22 +0000
commit15919b7c988af12708d89222bdebc6063d813dab (patch)
tree2226d3991caf7e14ca562bbfc8344dbde4578e6d
parent2ce07042fdbe7104694245b56006204ade9df34a (diff)
downloadNim-15919b7c988af12708d89222bdebc6063d813dab.tar.gz
EOS exception now contains the error code.
-rw-r--r--lib/pure/os.nim11
-rw-r--r--lib/system.nim1
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index bfecc569a..faca17e98 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -260,11 +260,12 @@ proc osError*(errorCode: TOSErrorCode) =
   ##
   ## If the error code is ``0`` or an error message could not be retrieved,
   ## the message ``unknown OS error`` will be used.
-  let msg = osErrorMsg(errorCode)
-  if msg == "":
-    raise newException(EOS, "unknown OS error")
-  else:
-    raise newException(EOS, msg)
+  var e: ref EOS; new(e)
+  e.errorCode = errorCode.int32
+  e.msg = osErrorMsg(errorCode)
+  if e.msg == "":
+    e.msg = "unknown OS error"
+  raise e
 
 {.push stackTrace:off.}
 proc osLastError*(): TOSErrorCode =
diff --git a/lib/system.nim b/lib/system.nim
index 24ad50f97..41624bb05 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -260,6 +260,7 @@ type
                               ## system raises.
   EIO* = object of ESystem    ## raised if an IO error occured.
   EOS* = object of ESystem    ## raised if an operating system service failed.
+    errorCode*: int32 ## OS-defined error code describing this error.
   EInvalidLibrary* = object of EOS ## raised if a dynamic library
                                    ## could not be loaded.
   EResourceExhausted* = object of ESystem ## raised if a resource request