Error -> Defect for defects (#13908)
* Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
This commit is contained in:
parent
cd9af6b804
commit
7d6cbf290a
92 changed files with 323 additions and 300 deletions
|
|
@ -81,13 +81,13 @@ foo(toOpenArray(seqq, 1, 3))
|
|||
# empty openArray issue #7904
|
||||
foo(toOpenArray(seqq, 0, -1))
|
||||
foo(toOpenArray(seqq, 1, 0))
|
||||
doAssertRaises(IndexError):
|
||||
doAssertRaises(IndexDefect):
|
||||
foo(toOpenArray(seqq, 0, -2))
|
||||
|
||||
foo(toOpenArray(arr, 9, 8))
|
||||
foo(toOpenArray(arr, 0, -1))
|
||||
foo(toOpenArray(arr, 1, 0))
|
||||
doAssertRaises(IndexError):
|
||||
doAssertRaises(IndexDefect):
|
||||
foo(toOpenArray(arr, 10, 8))
|
||||
|
||||
# test openArray of openArray
|
||||
|
|
@ -106,11 +106,11 @@ var arrNeg: array[-3 .. -1, int] = [1, 2, 3]
|
|||
foo(toOpenArray(arrNeg, -3, -1))
|
||||
foo(toOpenArray(arrNeg, 0, -1))
|
||||
foo(toOpenArray(arrNeg, -3, -4))
|
||||
doAssertRaises(IndexError):
|
||||
doAssertRaises(IndexDefect):
|
||||
foo(toOpenArray(arrNeg, -4, -1))
|
||||
doAssertRaises(IndexError):
|
||||
doAssertRaises(IndexDefect):
|
||||
foo(toOpenArray(arrNeg, -1, 0))
|
||||
doAssertRaises(IndexError):
|
||||
doAssertRaises(IndexDefect):
|
||||
foo(toOpenArray(arrNeg, -1, -3))
|
||||
doAssertRaises(Exception):
|
||||
raise newException(Exception, "foo")
|
||||
|
|
@ -118,9 +118,9 @@ doAssertRaises(Exception):
|
|||
block:
|
||||
var didThrow = false
|
||||
try:
|
||||
doAssertRaises(IndexError): # should fail since it's wrong exception
|
||||
raise newException(FieldError, "foo")
|
||||
except AssertionError:
|
||||
doAssertRaises(IndexDefect): # should fail since it's wrong exception
|
||||
raise newException(FieldDefect, "foo")
|
||||
except AssertionDefect:
|
||||
# ok, throwing was correct behavior
|
||||
didThrow = true
|
||||
doAssert didThrow
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue