Fix exception tracking for system.open (#10253)

This commit is contained in:
Oscar Nihlgård 2019-01-10 09:28:09 +01:00 • committed by Andreas Rumpf
commit 3ed5f83704

View file

@ -3237,14 +3237,15 @@ when not defined(JS): #and not defined(nimscript):
proc open*(f: var File, filename: string, proc open*(f: var File, filename: string,
mode: FileMode = fmRead, bufSize: int = -1): bool {.tags: [], mode: FileMode = fmRead, bufSize: int = -1): bool {.tags: [],
benign.} raises: [], benign.}
## Opens a file named `filename` with given `mode`. ## Opens a file named `filename` with given `mode`.
## ##
## Default mode is readonly. Returns true iff the file could be opened. ## Default mode is readonly. Returns true iff the file could be opened.
## This throws no exception if the file could not be opened. ## This throws no exception if the file could not be opened.
proc open*(f: var File, filehandle: FileHandle, proc open*(f: var File, filehandle: FileHandle,
mode: FileMode = fmRead): bool {.tags: [], benign.} mode: FileMode = fmRead): bool {.tags: [], raises: [],
benign.}
## Creates a ``File`` from a `filehandle` with given `mode`. ## Creates a ``File`` from a `filehandle` with given `mode`.
## ##
## Default mode is readonly. Returns true iff the file could be opened. ## Default mode is readonly. Returns true iff the file could be opened.
@ -3253,7 +3254,7 @@ when not defined(JS): #and not defined(nimscript):
mode: FileMode = fmRead, bufSize: int = -1): File = mode: FileMode = fmRead, bufSize: int = -1): File =
## Opens a file named `filename` with given `mode`. ## Opens a file named `filename` with given `mode`.
## ##
## Default mode is readonly. Raises an ``IO`` exception if the file ## Default mode is readonly. Raises an ``IOError`` if the file
## could not be opened. ## could not be opened.
if not open(result, filename, mode, bufSize): if not open(result, filename, mode, bufSize):
sysFatal(IOError, "cannot open: ", filename) sysFatal(IOError, "cannot open: ", filename)