From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- libcult/documentation/eh/index.xhtml | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 libcult/documentation/eh/index.xhtml (limited to 'libcult/documentation/eh') diff --git a/libcult/documentation/eh/index.xhtml b/libcult/documentation/eh/index.xhtml new file mode 100644 index 0000000..7847c11 --- /dev/null +++ b/libcult/documentation/eh/index.xhtml @@ -0,0 +1,106 @@ + + + + + + + + + libcult/documentation/eh + + + + + + + + + + + + + + +
+

The libcult exception handling library defines a base +exception type to be used by the rest of libcult. It has +a very basic interface:

+ +
+namespace Cult
+{
+  namespace EH
+  {
+    class Exception: public virtual std::exception
+    {
+    public:
+      virtual char const*
+      what () const throw ();
+    };
+  }
+}
+
+ +

It derives from std::exception to allow catching +all exceptions with a single handler. Default implementation of the +what() member function returns type-name of the exception. +

+ +

Every non-trivial library in libcult derives its own +base exception which all library-defined exceptions inherit. This +way you can catch all exceptions from a library with one handler.

+ +

Sometimes it may seem convenient to further partition (by providing +corresponding base classes) exceptions space into logic +exceptions (shared by all implementations) and implementation +exceptions. For example, if you pass an allocator illegal size 0 then +the allocator throws an exception which can be classified as a logic +exception. If, however, you passed valid size but there is not enough +memory then the allocator throws an exception which can be classified +as an implementation exception1.

+ +

The problem with this approach lies in the fact that someone's logic +exception is someone else's implementation exception. Consider, for +instance, a buffer type that is implemented in terms of our allocator. +If the buffer happened to request a memory block of size 0 and let +the exception propagate through the interface boundaries it is no longer +a logic exception.

+ + +
+
+

1 It can be argued that the +NoMemory exception should rather be classified +as logic. However, let's assume there are allocator implementations +that have infinite memory.

+
+ +
+ +
+

Copyright © 2005-2010 Boris Kolpackov.

+ +
+Permission is granted to copy, distribute and/or modify this document under +the terms of the GNU Free +Documentation License, version 1.2; with no Invariant Sections, no +Front-Cover Texts and no Back-Cover Texts. +
+
+ + + -- cgit v1.2.3