File 0302-erlang-module-doc-Improve-documentation-for-erlang-t.patch of Package erlang
From fa2fa66d07f515605474b5bfff53936906956044 Mon Sep 17 00:00:00 2001
From: Kjell Winblad <kjellwinblad@gmail.com>
Date: Thu, 27 Aug 2020 14:10:59 +0200
Subject: [PATCH 02/39] erlang module doc: Improve documentation for
erlang:throw/1
* Add links to documentation about catching exception
* Add try-catch example
---
erts/doc/src/erlang.xml | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml
index 3a2e3b0a46..b079e11ef0 100644
--- a/erts/doc/src/erlang.xml
+++ b/erts/doc/src/erlang.xml
@@ -10272,16 +10272,29 @@ hello
<name name="throw" arity="1" since=""/>
<fsummary>Throw an exception.</fsummary>
<desc>
- <p>A non-local return from a function. If evaluated within a
- <c>catch</c>, <c>catch</c> returns value <c><anno>Any</anno></c>.
- Example:</p>
+ <p>Used to raise exceptions and to do non-local returns from functions.</p>
+ <p>If evaluated within a
+ <seeguide marker="system/reference_manual:expressions#catch">
+ catch expression</seeguide>, the catch expression returns value <c><anno>Any</anno></c>.
+ Example:
<pre>
> <input>catch throw({hello, there}).</input>
-{hello,there}</pre>
- <p>Failure: <c>nocatch</c> if not evaluated within a catch.</p>
+ {hello,there}</pre>
+ </p>
+ <p>If evaluated within a
+ <c>try</c>-block of a <seeguide marker="system/reference_manual:expressions#try">try expression</seeguide>, the value <c><anno>Any</anno></c> can be caught within the catch block.
+ Example:
+ <code>
+try
+ throw({my_exception, "Something happened"})
+catch
+ {my_exception, Desc} ->
+ io:format(standard_error, "Error: ~s~n", [Desc])
+end</code>
+ </p>
+ <p>Failure: <c>nocatch</c> if not caught by an exception handler.</p>
</desc>
</func>
-
<func>
<name name="time" arity="0" since=""/>
<fsummary>Current time.</fsummary>
--
2.26.2