From 725c7caa027ff9e04ad514bade72163522c8d28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Tue, 20 Oct 2020 13:36:19 +0200 Subject: [PATCH] Remove bit about opening files not raising (#15654) Resolved #473 I am removing this bit because this advice to not throw on recoverable-from cases like a file failing to open is actually not respected by Nim standard library. `readFile` and `readLines` both throw and exceptions must be used as a method of control flow for the recovery from that. There are alternatives, like opening a file handle instead of using these helpers, but that's less convenient than these helper methods for cases where you really want to just slurp up a file to memory and use a fallback value if it doesn't exist or is for whatever reason not readable. --- doc/tut2.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/tut2.rst b/doc/tut2.rst index ac8e82b0ad..577b65622c 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -345,10 +345,8 @@ The compiler will prevent you from raising an exception created on the stack. All raised exceptions should at least specify the reason for being raised in the ``msg`` field. -A convention is that exceptions should be raised in *exceptional* cases: -For example, if a file cannot be opened, this should not raise an -exception since this is quite common (the file may not exist). - +A convention is that exceptions should be raised in *exceptional* cases, +they should not be used as an alternative method of control flow. Raise statement ---------------