Improve exception tracking in the streams module (#10453)
This commit is contained in:
parent
9402c82e80
commit
ac8f6c57a1
2 changed files with 18 additions and 21 deletions
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
- The procs `parseutils.parseBiggsetInt`, `parseutils.parseInt`, `parseutils.parseBiggestUInt` and `parseutils.parseUInt` now raise a `ValueError` when the parsed integer is outside of the valid range. Previously they sometimes raised a `OverflowError` and sometimes returned `0`.
|
- The procs `parseutils.parseBiggsetInt`, `parseutils.parseInt`, `parseutils.parseBiggestUInt` and `parseutils.parseUInt` now raise a `ValueError` when the parsed integer is outside of the valid range. Previously they sometimes raised a `OverflowError` and sometimes returned `0`.
|
||||||
|
|
||||||
|
- `streams.StreamObject` now restricts its fields to only raise `system.Defect`, `system.IOError` and `system.OSError`. This change only affects custom stream implementations.
|
||||||
|
|
||||||
- nre's `RegexMatch.{captureBounds,captures}[]` no longer return `Option` or
|
- nre's `RegexMatch.{captureBounds,captures}[]` no longer return `Option` or
|
||||||
`nil`/`""`, respectivly. Use the newly added `n in p.captures` method to
|
`nil`/`""`, respectivly. Use the newly added `n in p.captures` method to
|
||||||
check if a group is captured, otherwise you'll recieve an exception.
|
check if a group is captured, otherwise you'll recieve an exception.
|
||||||
|
|
|
||||||
|
|
@ -45,17 +45,22 @@ type
|
||||||
## here shouldn't be used directly. They are
|
## here shouldn't be used directly. They are
|
||||||
## accessible so that a stream implementation
|
## accessible so that a stream implementation
|
||||||
## can override them.
|
## can override them.
|
||||||
closeImpl*: proc (s: Stream) {.nimcall, tags: [], gcsafe.}
|
closeImpl*: proc (s: Stream)
|
||||||
atEndImpl*: proc (s: Stream): bool {.nimcall, tags: [], gcsafe.}
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
|
||||||
setPositionImpl*: proc (s: Stream, pos: int) {.nimcall, tags: [], gcsafe.}
|
atEndImpl*: proc (s: Stream): bool
|
||||||
getPositionImpl*: proc (s: Stream): int {.nimcall, tags: [], gcsafe.}
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
|
||||||
readDataImpl*: proc (s: Stream, buffer: pointer,
|
setPositionImpl*: proc (s: Stream, pos: int)
|
||||||
bufLen: int): int {.nimcall, tags: [ReadIOEffect], gcsafe.}
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
|
||||||
peekDataImpl*: proc (s: Stream, buffer: pointer,
|
getPositionImpl*: proc (s: Stream): int
|
||||||
bufLen: int): int {.nimcall, tags: [ReadIOEffect], gcsafe.}
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [], gcsafe.}
|
||||||
writeDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int) {.nimcall,
|
readDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int): int
|
||||||
tags: [WriteIOEffect], gcsafe.}
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
|
||||||
flushImpl*: proc (s: Stream) {.nimcall, tags: [WriteIOEffect], gcsafe.}
|
peekDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int): int
|
||||||
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
|
||||||
|
writeDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int)
|
||||||
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [WriteIOEffect], gcsafe.}
|
||||||
|
flushImpl*: proc (s: Stream)
|
||||||
|
{.nimcall, raises: [Defect, IOError, OSError], tags: [WriteIOEffect], gcsafe.}
|
||||||
|
|
||||||
proc flush*(s: Stream) =
|
proc flush*(s: Stream) =
|
||||||
## flushes the buffers that the stream `s` might use.
|
## flushes the buffers that the stream `s` might use.
|
||||||
|
|
@ -65,10 +70,6 @@ proc close*(s: Stream) =
|
||||||
## closes the stream `s`.
|
## closes the stream `s`.
|
||||||
if not isNil(s.closeImpl): s.closeImpl(s)
|
if not isNil(s.closeImpl): s.closeImpl(s)
|
||||||
|
|
||||||
proc close*(s, unused: Stream) {.deprecated.} =
|
|
||||||
## closes the stream `s`.
|
|
||||||
s.closeImpl(s)
|
|
||||||
|
|
||||||
proc atEnd*(s: Stream): bool =
|
proc atEnd*(s: Stream): bool =
|
||||||
## checks if more data can be read from `f`. Returns true if all data has
|
## checks if more data can be read from `f`. Returns true if all data has
|
||||||
## been read.
|
## been read.
|
||||||
|
|
@ -111,12 +112,6 @@ proc writeData*(s: Stream, buffer: pointer, bufLen: int) =
|
||||||
## to the stream `s`.
|
## to the stream `s`.
|
||||||
s.writeDataImpl(s, buffer, bufLen)
|
s.writeDataImpl(s, buffer, bufLen)
|
||||||
|
|
||||||
proc writeData*(s, unused: Stream, buffer: pointer,
|
|
||||||
bufLen: int) {.deprecated.} =
|
|
||||||
## low level proc that writes an untyped `buffer` of `bufLen` size
|
|
||||||
## to the stream `s`.
|
|
||||||
s.writeDataImpl(s, buffer, bufLen)
|
|
||||||
|
|
||||||
proc write*[T](s: Stream, x: T) =
|
proc write*[T](s: Stream, x: T) =
|
||||||
## generic write procedure. Writes `x` to the stream `s`. Implementation:
|
## generic write procedure. Writes `x` to the stream `s`. Implementation:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue