summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-05-20 23:00:25 +0200
committerAraq <rumpf_a@web.de>2018-05-20 23:00:39 +0200
commit5472574f721ae08cb696f4129abcff54e1e88d83 (patch)
tree956af5e385f610a61b67c0c134ba04ebe5411248 /lib/pure
parent90afb1baa7cd4c047093f6cb108c954cb3cb6ca9 (diff)
downloadNim-5472574f721ae08cb696f4129abcff54e1e88d83.tar.gz
json.nim: delete should raise KeyError, not IndexError, minor cleanup of the tests
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/json.nim8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index ca7e164b8..2bb830bcb 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -509,7 +509,7 @@ proc delete*(obj: JsonNode, key: string) =
   ## Deletes ``obj[key]``.
   assert(obj.kind == JObject)
   if not obj.fields.hasKey(key):
-    raise newException(IndexError, "key not in object")
+    raise newException(KeyError, "key not in object")
   obj.fields.del(key)
 
 proc copy*(p: JsonNode): JsonNode =
@@ -1496,18 +1496,18 @@ when isMainModule:
   # Bounds checking
   try:
     let a = testJson["a"][9]
-    doAssert(false, "EInvalidIndex not thrown")
+    doAssert(false, "IndexError not thrown")
   except IndexError:
     discard
   try:
     let a = testJson["a"][-1]
-    doAssert(false, "EInvalidIndex not thrown")
+    doAssert(false, "IndexError not thrown")
   except IndexError:
     discard
   try:
     doAssert(testJson["a"][0].num == 1, "Index doesn't correspond to its value")
   except:
-    doAssert(false, "EInvalidIndex thrown for valid index")
+    doAssert(false, "IndexError thrown for valid index")
 
   doAssert(testJson{"b"}.str=="asd", "Couldn't fetch a singly nested key with {}")
   doAssert(isNil(testJson{"nonexistent"}), "Non-existent keys should return nil")