From f79774e766a925fbe6347274dc19104e468eb54a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Tue, 10 Nov 2020 21:28:56 +0100 Subject: [PATCH] updated raises annotations --- yaml/dom.nim | 4 ++++ yaml/presenter.nim | 5 +++-- yaml/serialization.nim | 5 ++++- yaml/tojson.nim | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/yaml/dom.nim b/yaml/dom.nim index 8520c32..46bcc83 100644 --- a/yaml/dom.nim +++ b/yaml/dom.nim @@ -208,6 +208,8 @@ proc loadDom*(s: Stream | string): YamlDocument raise (ref YamlParserError)(ex.parent) elif ex.parent of IOError: raise (ref IOError)(ex.parent) + elif ex.parent of OSError: + raise (ref OSError)(ex.parent) else: internalError("Unexpected exception: " & ex.parent.repr) proc loadMultiDom*(s: Stream | string): seq[YamlDocument] @@ -230,6 +232,8 @@ proc loadMultiDom*(s: Stream | string): seq[YamlDocument] raise (ref YamlParserError)(ex.parent) elif ex.parent of IOError: raise (ref IOError)(ex.parent) + elif ex.parent of OSError: + raise (ref OSError)(ex.parent) else: internalError("Unexpected exception: " & ex.parent.repr) proc serializeNode(n: YamlNode, c: SerializationContext, a: AnchorStyle, diff --git a/yaml/presenter.nim b/yaml/presenter.nim index 13e4146..99fc798 100644 --- a/yaml/presenter.nim +++ b/yaml/presenter.nim @@ -793,6 +793,7 @@ proc doTransform(c: var Context, input: Stream, var e = getCurrentException() while e.parent of YamlStreamError: e = e.parent if e.parent of IOError: raise (ref IOError)(e.parent) + elif e.parent of OSError: raise (ref OSError)(e.parent) elif e.parent of YamlParserError: raise (ref YamlParserError)(e.parent) else: internalError("Unexpected exception: " & e.parent.repr) @@ -802,7 +803,7 @@ proc genInput(input: string): Stream = newStringStream(input) proc transform*(input: Stream | string, output: Stream, options: PresentationOptions = defaultPresentationOptions, resolveToCoreYamlTags: bool = false) - {.raises: [IOError, YamlParserError, YamlPresenterJsonError, + {.raises: [IOError, OSError, YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].} = ## Parser ``input`` as YAML character stream and then dump it to ``output`` ## while resolving non-specific tags to the ones in the YAML core tag @@ -813,7 +814,7 @@ proc transform*(input: Stream | string, output: Stream, proc transform*(input: Stream | string, options: PresentationOptions = defaultPresentationOptions, resolveToCoreYamlTags: bool = false): - string {.raises: [IOError, YamlParserError, YamlPresenterJsonError, + string {.raises: [IOError, OSError, YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].} = ## Parser ``input`` as YAML character stream, resolves non-specific tags to ## the ones in the YAML core tag library, and then returns a serialized diff --git a/yaml/serialization.nim b/yaml/serialization.nim index 148bd1f..ddbaead 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -1372,10 +1372,12 @@ proc load*[K](input: Stream | string, target: var K) except YamlStreamError: let e = (ref YamlStreamError)(getCurrentException()) if e.parent of IOError: raise (ref IOError)(e.parent) + if e.parent of OSError: raise (ref OSError)(e.parent) elif e.parent of YamlParserError: raise (ref YamlParserError)(e.parent) else: internalError("Unexpected exception: " & $e.parent.name) -proc loadAs*[K](input: string): K {.raises: [YamlConstructionError, IOError, YamlParserError].} = +proc loadAs*[K](input: string): K {.raises: + [YamlConstructionError, IOError, OSError, YamlParserError].} = ## Loads the given YAML input to a value of the type K and returns it load(input, result) @@ -1399,6 +1401,7 @@ proc loadMultiDoc*[K](input: Stream | string, target: var seq[K]) = except YamlStreamError: let e = (ref YamlStreamError)(getCurrentException()) if e.parent of IOError: raise (ref IOError)(e.parent) + elif e.parent of OSError: raise (ref OSError)(e.parent) elif e.parent of YamlParserError: raise (ref YamlParserError)(e.parent) else: internalError("Unexpected exception: " & $e.parent.name) diff --git a/yaml/tojson.nim b/yaml/tojson.nim index 5dbc3f5..812302a 100644 --- a/yaml/tojson.nim +++ b/yaml/tojson.nim @@ -191,6 +191,8 @@ when not defined(JS): let e = getCurrentException() if e.parent of IOError: raise (ref IOError)(e.parent) + elif e.parent of OSError: + raise (ref OSError)(e.parent) elif e.parent of YamlParserError: raise (ref YamlParserError)(e.parent) else: internalError("Unexpected exception: " & e.parent.repr)