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:
Jacek Sieka 2020-04-28 19:56:01 +02:00 • committed by GitHub
commit 7d6cbf290a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 323 additions and 300 deletions

View file

@ -126,7 +126,7 @@ The syntax for type conversions is ``destination_type(expression_to_convert)``
proc getID(x: Person): int =
Student(x).id
The ``InvalidObjectConversionError`` exception is raised if ``x`` is not a
The ``InvalidObjectConversionDefect`` exception is raised if ``x`` is not a
``Student``.
@ -160,7 +160,7 @@ An example:
condition, thenPart, elsePart: Node
var n = Node(kind: nkFloat, floatVal: 1.0)
# the following statement raises an `FieldError` exception, because
# the following statement raises an `FieldDefect` exception, because
# n.kind's value does not fit:
n.strVal = ""
@ -388,7 +388,7 @@ The ``try`` statement handles exceptions:
let a = readLine(f)
let b = readLine(f)
echo "sum: ", parseInt(a) + parseInt(b)
except OverflowError:
except OverflowDefect:
echo "overflow!"
except ValueError:
echo "could not convert string to integer"
@ -443,7 +443,7 @@ instance, if you specify that a proc raises ``IOError``, and at some point it
prevent that proc from compiling. Usage example:
.. code-block:: nim
proc complexProc() {.raises: [IOError, ArithmeticError].} =
proc complexProc() {.raises: [IOError, ArithmeticDefect].} =
...
proc simpleProc() {.raises: [].} =