From aea819b89a1629a8dcf6ea8904986500b33a2e36 Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 13 Jun 2025 01:45:33 +0400 Subject: [PATCH] refs #22 docs reordered chapters --- docs/exceptions_handling.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/exceptions_handling.md b/docs/exceptions_handling.md index 5f4242e..fd07c94 100644 --- a/docs/exceptions_handling.md +++ b/docs/exceptions_handling.md @@ -81,6 +81,22 @@ to catch all exceptions to, then you can write it even shorter: You can even check the type of the `it` and create more convenient and sophisticated processing logic. Such approach is used, for example, in Scala. +## finally block + +If `finally` block present, it will be executed after body (until first exception) +and catch block, if any will match. finally statement is executed even if the +exception will be thrown and not caught locally. It does not alter try/catch block result: + + try { + } + finally { + println("called finally") + } + >>> called finally + >>> void + +- and yes, there could be try-finally block, no catching, but perform some guaranteed cleanup. + # Conveying data with exceptions The simplest way is to provide exception string and `Exception` class: @@ -106,22 +122,6 @@ This way, in turn, can also be shortened, as it is overly popular: The trick, though, works with strings only, and always provide `Exception` instances, which is good for debugging but most often not enough. -## finally block - -If `finally` block present, it will be executed after body (until first exception) -and catch block, if any will match. finally statement is executed even if the -exception will be thrown and not caught locally. It does not alter try/catch block result: - - try { - } - finally { - println("called finally") - } - >>> called finally - >>> void - -- and yes, there could be try-finally block, no catching, but perform some guaranteed cleanup. - # Custom error classes _this functionality is not yet released_