summaryrefslogtreecommitdiffstats
path: root/docs/ProgrammersManual.rst
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-11-07 22:33:13 +0000
committerLang Hames <lhames@gmail.com>2016-11-07 22:33:13 +0000
commit3fab9364acb98f658f4eb49b9b9b14acca93d282 (patch)
treea50d54951798e03f12ac56ddf8ba7dd468d3ba7c /docs/ProgrammersManual.rst
parent3e9cd162c09c1ddd1071536157110d494550521c (diff)
[docs] Add a pointer to ExitOnError to the discussion of handleErrors in the
programmer's manual. ExitOnError is often a better alternative to handleErrors for tool code. This patch makes it easier to find the ExitOnError discussion when reading the handleErrors section. Thanks to Peter Collingbourne for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ProgrammersManual.rst')
-rw-r--r--docs/ProgrammersManual.rst11
1 files changed, 9 insertions, 2 deletions
diff --git a/docs/ProgrammersManual.rst b/docs/ProgrammersManual.rst
index adf6fd62fc98..e4d3ddb7bd9d 100644
--- a/docs/ProgrammersManual.rst
+++ b/docs/ProgrammersManual.rst
@@ -469,8 +469,8 @@ a variadic list of "handlers", each of which must be a callable type (a
function, lambda, or class with a call operator) with one argument. The
``handleErrors`` function will visit each handler in the sequence and check its
argument type against the dynamic type of the error, running the first handler
-that matches. This is the same process that is used for catch clauses in C++
-exceptions.
+that matches. This is the same decision process that is used decide which catch
+clause to run for a C++ exception.
Since the list of handlers passed to ``handleErrors`` may not cover every error
type that can occur, the ``handleErrors`` function also returns an Error value
@@ -500,6 +500,11 @@ elsewhere in the program can easily turn a formerly exhaustive list of errors
into a non-exhaustive list, risking unexpected program termination. Where
possible, use handleErrors and propagate unknown errors up the stack instead.
+For tool code, where errors can be handled by printing an error message then
+exiting with an error code, the :ref:`ExitOnError <err_exitonerr>` utility
+may be a better choice than handleErrors, as it simplifies control flow when
+calling fallible functions.
+
StringError
"""""""""""
@@ -580,6 +585,8 @@ actually recognises three different forms of handler signature:
Any error returned from a handler will be returned from the ``handleErrors``
function so that it can be handled itself, or propagated up the stack.
+.. _err_exitonerr:
+
Using ExitOnError to simplify tool code
"""""""""""""""""""""""""""""""""""""""