<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Handling_Exceptions_Gracefully</id>
		<title>Handling Exceptions Gracefully - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Handling_Exceptions_Gracefully"/>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;action=history"/>
		<updated>2026-04-07T21:56:00Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11678&amp;oldid=prev</id>
		<title>Paulb at 16:05, 2 October 2008</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11678&amp;oldid=prev"/>
				<updated>2008-10-02T16:05:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:05, 2 October 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 210:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 210:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One final semantic explanation is required, this in regards to abnormal execution inside of a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause. I would suggest the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is exited, as would a routine body in an exception case. Then, for simplicity, any &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause, whether executed or not, is skipped and the exception propagated to the caller. The semantics should retain the same behavior as if there were an exception in the rescue clause. The rule adhere to is &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clauses should be free, as possible, of exception-possible scenarios. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One final semantic explanation is required, this in regards to abnormal execution inside of a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause. I would suggest the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is exited, as would a routine body in an exception case. Then, for simplicity, any &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause, whether executed or not, is skipped and the exception propagated to the caller. The semantics should retain the same behavior as if there were an exception in the rescue clause. The rule adhere to is &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clauses should be free, as possible, of exception-possible scenarios. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Trying to provide smarter execution semantics based on the execution of a &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clauses and whether or not a &amp;lt;e&amp;gt;retry&amp;lt;/e&amp;gt; has been performed would only cause likely confusion as to when, how and how many times a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is execution, as well as increasing the possible debug paths needed to be &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;traces &lt;/del&gt;to ensure the routine correctly handles all anomalies.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Trying to provide smarter execution semantics based on the execution of a &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clauses and whether or not a &amp;lt;e&amp;gt;retry&amp;lt;/e&amp;gt; has been performed would only cause likely confusion as to when, how and how many times a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is execution, as well as increasing the possible debug paths needed to be &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;traced &lt;/ins&gt;to ensure the routine correctly handles all anomalies.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paulb</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11677&amp;oldid=prev</id>
		<title>Paulb at 16:02, 2 October 2008</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11677&amp;oldid=prev"/>
				<updated>2008-10-02T16:02:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:02, 2 October 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 80:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 80:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Great, we are safe! There quite a bit of extra logic in there just to make sure we clean everything up correctly.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Great, we are safe! There quite a bit of extra logic in there just to make sure we clean everything up correctly.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;But wait! The exception shouldn't just be ignored! After all it is an exception case and the user should be notified something went wrong. The rescue clause as it stands prevents the exception from being propagated to the caller, creating a silent failure and most perplexing scenario for the user - It just doesn't work and they have no idea why! An unwinding of the stack should discover a rescue clause able to correctly deal with the network exception and present the user with some form of UI or notification of the failure. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;But wait! The exception shouldn't just be ignored! After all it is an exception case and the user should be notified something went wrong. The rescue clause as it stands prevents the exception from being propagated to the caller, creating a silent failure and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a &lt;/ins&gt;most perplexing scenario for the user - It just doesn't work and they have no idea why! An unwinding of the stack should discover a rescue clause able to correctly deal with the network exception and present the user with some form of UI or notification of the failure. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Exception Propagation (Re-Raise) ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Exception Propagation (Re-Raise) ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paulb</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11675&amp;oldid=prev</id>
		<title>Paulb at 22:42, 1 October 2008</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11675&amp;oldid=prev"/>
				<updated>2008-10-01T22:42:34Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:42, 1 October 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ECMA]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ECMA]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Author: [[User:Paulb| Paul Bates]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Preface==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Exceptions have been in the Eiffel language for a little while now, and even before the [[Exceptions as Objects]] mechanism was implemented, exceptions still appeared when running Eiffel systems. No matter how hard we might try to engineer our code to be safe and free of expensive exception conditioning, it'll still happen. One need not do anything complex or contrived, an exception is possibly even in the most basic of engineered systems. There are memory, file, networking exception and even mutexes concerns to regard when working with such rudimentary facilities. There and myriad of exception cases and many more cases where code is written to protect against these cases, but code is either duplicated or forgotten about.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Exceptions have been in the Eiffel language for a little while now, and even before the [[Exceptions as Objects]] mechanism was implemented, exceptions still appeared when running Eiffel systems. No matter how hard we might try to engineer our code to be safe and free of expensive exception conditioning, it'll still happen. One need not do anything complex or contrived, an exception is possibly even in the most basic of engineered systems. There are memory, file, networking exception and even mutexes concerns to regard when working with such rudimentary facilities. There and myriad of exception cases and many more cases where code is written to protect against these cases, but code is either duplicated or forgotten about.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paulb</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11674&amp;oldid=prev</id>
		<title>Paulb: Added page on a final clause idea.</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Handling_Exceptions_Gracefully&amp;diff=11674&amp;oldid=prev"/>
				<updated>2008-10-01T22:41:11Z</updated>
		
		<summary type="html">&lt;p&gt;Added page on a final clause idea.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:ECMA]]&lt;br /&gt;
&lt;br /&gt;
Exceptions have been in the Eiffel language for a little while now, and even before the [[Exceptions as Objects]] mechanism was implemented, exceptions still appeared when running Eiffel systems. No matter how hard we might try to engineer our code to be safe and free of expensive exception conditioning, it'll still happen. One need not do anything complex or contrived, an exception is possibly even in the most basic of engineered systems. There are memory, file, networking exception and even mutexes concerns to regard when working with such rudimentary facilities. There and myriad of exception cases and many more cases where code is written to protect against these cases, but code is either duplicated or forgotten about.&lt;br /&gt;
&lt;br /&gt;
== An Example ==&lt;br /&gt;
I'm getting ahead of myself, I digress. I'm going to illustrate a simple example for which this page is based. It's a functional system the preforms some operations based on a state attribute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
perform (args: OPTIONS)&lt;br /&gt;
        -- Perform an operation.&lt;br /&gt;
    require&lt;br /&gt;
        ...&lt;br /&gt;
    local&lt;br /&gt;
        l_state: like current_state&lt;br /&gt;
    do&lt;br /&gt;
            -- Ensure we are processing everything.&lt;br /&gt;
        l_state := current_state&lt;br /&gt;
        if l_state /= process_all then&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
            -- Perform operations.&lt;br /&gt;
        ... &lt;br /&gt;
            -- End operations.&lt;br /&gt;
&lt;br /&gt;
        if l_state /= process_all then&lt;br /&gt;
                -- Reset the current state.&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
    ensure&lt;br /&gt;
        current_state_unchanged: current_state = old current_state&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not much is seemingly wrong with the above code. It appears to be a good citizen of the system and restores any changes made to the system before executing.&lt;br /&gt;
&lt;br /&gt;
Debugging the completed system goes without a hitch and everything works just fine. Yet a released, finalized version doesn't behave as expected and no cause can be found. This is classic example of anomalies that can happen during execution on an end-user system, where any number of applications can be running and system set ups vary drastically, with each and all a potential malevolent entity.&lt;br /&gt;
&lt;br /&gt;
For the sake of example, I'm going to pretend the operation being performed is some communication over a network, because networks are susceptible to any magnitude of failures, at any point; a power outage, a disconnected Ethernet cable, a router just failing because of age, router firmware/software issues or and earthquake just rocked it off the shelf and caused it to break when hitting the floor. I could be here all day...&lt;br /&gt;
&lt;br /&gt;
=== Exception Protection ===&lt;br /&gt;
Let's protect the code and make sure that current_state attribute is reset and the post-condition ensured, then in the event of a failure the system resides in a correct state according to the explicit contracts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
perform (args: OPTIONS)&lt;br /&gt;
        -- Perform an operation.&lt;br /&gt;
    require&lt;br /&gt;
        ...&lt;br /&gt;
    local&lt;br /&gt;
        l_state: like current_state&lt;br /&gt;
        retried: BOOLEAN&lt;br /&gt;
    do&lt;br /&gt;
        if not retried then&lt;br /&gt;
                -- Ensure we are processing everything.&lt;br /&gt;
            l_state := current_state&lt;br /&gt;
            if l_state /= process_all then&lt;br /&gt;
                set_current_state (l_state)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
               -- Perform operations.&lt;br /&gt;
           ... &lt;br /&gt;
               -- End operations.&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if  l_state /= process_all then&lt;br /&gt;
                -- Reset the current state.&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
    ensure&lt;br /&gt;
        current_state_unchanged: current_state = old current_state&lt;br /&gt;
    rescue&lt;br /&gt;
            -- There was a network failure.&lt;br /&gt;
        retried := True&lt;br /&gt;
        retry&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Great, we are safe! There quite a bit of extra logic in there just to make sure we clean everything up correctly.&lt;br /&gt;
&lt;br /&gt;
But wait! The exception shouldn't just be ignored! After all it is an exception case and the user should be notified something went wrong. The rescue clause as it stands prevents the exception from being propagated to the caller, creating a silent failure and most perplexing scenario for the user - It just doesn't work and they have no idea why! An unwinding of the stack should discover a rescue clause able to correctly deal with the network exception and present the user with some form of UI or notification of the failure. &lt;br /&gt;
&lt;br /&gt;
=== Exception Propagation (Re-Raise) ===&lt;br /&gt;
&lt;br /&gt;
This seems to be a critical detail not to be over looked. This is especially true for libraries where clients may need to be notified of failures in some way. Let's support this by extending the example once more:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
perform (args: OPTIONS)&lt;br /&gt;
        -- Perform an operation.&lt;br /&gt;
    require&lt;br /&gt;
        ...&lt;br /&gt;
    local&lt;br /&gt;
        l_state: like current_state&lt;br /&gt;
        l_manager: !EXCEPTION_MANAGER&lt;br /&gt;
        retried: BOOLEAN&lt;br /&gt;
    do&lt;br /&gt;
        if not retried then&lt;br /&gt;
                -- Ensure we are processing everything.&lt;br /&gt;
            l_state := current_state&lt;br /&gt;
            if l_state /= process_all then&lt;br /&gt;
                set_current_state (process_all)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
               -- Perform operations.&lt;br /&gt;
           ... &lt;br /&gt;
               -- End operations.&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if  l_state /= process_all then&lt;br /&gt;
                -- Reset the current state.&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if retried then&lt;br /&gt;
                -- Re-raise the exception.&lt;br /&gt;
            create l_manager&lt;br /&gt;
            l_manager.raise (l_manager.last_exception)&lt;br /&gt;
        end&lt;br /&gt;
    ensure&lt;br /&gt;
        current_state_unchanged: current_state = old current_state&lt;br /&gt;
    rescue&lt;br /&gt;
        if not retried then&lt;br /&gt;
            retried := True&lt;br /&gt;
            retry&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the safest, and a non-code duplicating way of doing things. This time we garnish the &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause with an conditional check to ensure the routine is not re-rescued. At the end of the routine body the last exception is re-raised (very crudely I might add), so the exception can be propagated up to the caller or the next unwound stack frame capable of handling the exception correctly.&lt;br /&gt;
&lt;br /&gt;
So now two exceptions are being raised. The original network exception and now one used for propagation. This is a performance hit because exceptions are computationally expensive. This is ideal in some scenarios to report a more specific type of exception, but for the example, it's wasted processing power to ensure our system is in a correct state.&lt;br /&gt;
&lt;br /&gt;
=== Exception Propagation (Pass-Through) ===&lt;br /&gt;
&lt;br /&gt;
There is another way, without re-raising the last exception - passing the exception through the routine, by not retrying at the time of rescue:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
perform (args: OPTIONS)&lt;br /&gt;
        -- Perform an operation.&lt;br /&gt;
    require&lt;br /&gt;
        ...&lt;br /&gt;
    local&lt;br /&gt;
        l_state: like current_state&lt;br /&gt;
    do&lt;br /&gt;
            -- Ensure we are processing everything.&lt;br /&gt;
        l_state := current_state&lt;br /&gt;
        if l_state /= process_all then&lt;br /&gt;
            set_current_state (process_all)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
           -- Perform operations.&lt;br /&gt;
       ... &lt;br /&gt;
           -- End operations.&lt;br /&gt;
&lt;br /&gt;
        if  l_state /= process_all then&lt;br /&gt;
                -- Reset the current state.&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
    ensure&lt;br /&gt;
        current_state_unchanged: current_state = old current_state&lt;br /&gt;
    rescue&lt;br /&gt;
        if l_state /= process_all ten&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wow, that saved, seemingly, a lot of code at the expense of a little code duplication. Here the example is small and only one state attribute needs resetting, start adding more and you're causing a headache for any other reader, engineer, and even yourself. For one, code duplication is bad because any changes need to be reflected in all duplications, which also logically means both restore state code blocks needs to be tested/debugged for each change. In the example above the restore state code blocks are almost adjacent to each other so keeping the block synchronized doesn't seem to be much of a problem, but in real-world application it is likely that the rescue block resides a distance away from the routine body's restore state code, and may even be off-screen, potential causing an unsynchronized update and anomalies at runtime if not properly checked. This is in disregards to the fact that it's still an maintenance frustration because the likelihood is a copy and paste operation.&lt;br /&gt;
&lt;br /&gt;
To put the proverbial icing on the cake, let us take redefinition and &amp;lt;e&amp;gt;Precursor&amp;lt;/e&amp;gt; calls into account. Using the previous example with code duplication we can implement something that works just dandy, with the added overhead that we are duplicating code and exponentially doubling our time to debug. With the aforementioned re-raising of exceptions, there's still more verbose code as well as the overhead of re-raising yet another exception.&lt;br /&gt;
&lt;br /&gt;
== Introducing the Final Clause ==&lt;br /&gt;
&lt;br /&gt;
The solution to the problem of code complexities, without forsaking safety is to introduce an &amp;quot;alway-executed&amp;quot; routine block. Regardless of the state of exception of a routine body an always-executed code block will execute the code in a normal and abnormal execution.&lt;br /&gt;
&lt;br /&gt;
This is not a proposal, merely and idea. The alway-executed block, to be know as a ''final'' clause could look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
perform (args: OPTIONS)&lt;br /&gt;
        -- Perform an operation.&lt;br /&gt;
    require&lt;br /&gt;
        ...&lt;br /&gt;
    local&lt;br /&gt;
        l_state: like current_state&lt;br /&gt;
    do&lt;br /&gt;
            -- Ensure we are processing everything&lt;br /&gt;
        l_state := current_state&lt;br /&gt;
        if l_state /= process_all then&lt;br /&gt;
            set_current_state (process_all)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
           -- Perform operations.&lt;br /&gt;
       ... &lt;br /&gt;
           -- End operations.&lt;br /&gt;
    final&lt;br /&gt;
        if  l_state /= process_all then&lt;br /&gt;
                -- Reset the current state.&lt;br /&gt;
            set_current_state (l_state)&lt;br /&gt;
        end&lt;br /&gt;
    rescue&lt;br /&gt;
        ...&lt;br /&gt;
    ensure&lt;br /&gt;
        current_state_unchanged: current_state = old current_state&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the execution, during a normal execution path, the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause will be executed and then, after, any post-conditions. The clause remains functional to only the routine in which is resides, so inheritance and redefinition will play no part in its execution. On the contrary, during an abnormal execution path, execution will preform any operations defined in the &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause and then execute the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause. In the event a &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause requests a &amp;lt;e&amp;gt;retry&amp;lt;/e&amp;gt;, the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause will be executed after a successful or unsuccessful &amp;lt;e&amp;gt;retry&amp;lt;/e&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One final semantic explanation is required, this in regards to abnormal execution inside of a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause. I would suggest the &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is exited, as would a routine body in an exception case. Then, for simplicity, any &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clause, whether executed or not, is skipped and the exception propagated to the caller. The semantics should retain the same behavior as if there were an exception in the rescue clause. The rule adhere to is &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clauses should be free, as possible, of exception-possible scenarios. &lt;br /&gt;
&lt;br /&gt;
Trying to provide smarter execution semantics based on the execution of a &amp;lt;e&amp;gt;rescue&amp;lt;/e&amp;gt; clauses and whether or not a &amp;lt;e&amp;gt;retry&amp;lt;/e&amp;gt; has been performed would only cause likely confusion as to when, how and how many times a &amp;lt;e&amp;gt;final&amp;lt;/e&amp;gt; clause is execution, as well as increasing the possible debug paths needed to be traces to ensure the routine correctly handles all anomalies.&lt;/div&gt;</summary>
		<author><name>Paulb</name></author>	</entry>

	</feed>