DaemonLost class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (another tag or two)
mNo edit summary
Line 1: Line 1:
<!-- DaemonLost class -->
<!-- DaemonLost class -->
__NOTOC__
The <var>DaemonLost</var> exception class indicates that a daemon thread associated with a daemon object was lost, most probably because of a user restart.
The <var>DaemonLost</var> exception class indicates that a daemon thread associated with a daemon object was lost, most probably because of a user restart.
   
   
The <var>[[Run (Daemon function)|Run]]</var> function of the <var>[[Daemon_class|Daemon]]</var> system class is an example of a system method that automatically throws a <var>DaemonLost</var> exception.
The <var>[[Run (Daemon function)|Run]]</var> function of the <var>[[Daemon_class|Daemon]]</var> system class is an example of a system method that automatically throws a <var>DaemonLost</var> exception. For more information about catching a thrown exception, see "[[Try and Catch]]".
   
   
==Examples==
The following example shows a "[[Try and Catch]]" of a <var>DaemonLost</var> exception. The daemon request is contrived to produce a user restart to demonstrate <var>DaemonLost</var> exception output.
<ol><li>The following example shows a "[[Try and Catch]]" of a <var>DaemonLost</var> exception. The daemon request is contrived to produce a user restart to demonstrate <var>DaemonLost</var> exception output:
<p class="code">begin
<p class="code">begin
   %dmn    is object daemon
   %dmn    is object daemon
Line 32: Line 32:
ROSEBUD
ROSEBUD
</p>
</p>
<b><i>Note:</i></b> It is necessary to declare the exception object in the main thread of the program, but instantiating it is taken care of by the <var>[[Run (Daemon function)|Run]]</var> <var>[[Daemon_class|Daemon]]</var> method.
<b>Note:</b> It is necessary to declare the exception object in the main thread of the program, but instantiating it is taken care of by the <var>[[Run (Daemon function)|Run]]</var> <var>[[Daemon_class|Daemon]]</var> method.
   
   
<li>A request cancellation does not cause the daemon thread to go away, so it does not produce a <var>DaemonLost</var> exception.  Consequently, using the error count on the last command may be an adequate way
A request cancellation does not cause the daemon thread to go away, so it does not produce a <var>DaemonLost</var> exception.  Consequently, using the error count on the last command may be an adequate way
for your application to check for a request cancellation:
for your application to check for a request cancellation:
<p class="code">begin
<p class="code">begin
Line 58: Line 58:
</p>
</p>


<li>To produce a <var>DaemonLost</var> exception for a user-created method, you would issue a User Language Language <var>[[Throw]]</var> statement from within the method, and you must catch it in the code that called the method.  Because this exception is tailored to <var>daemon</var> execution by the system <var>Run</var> method, you are not likely to throw it from a user method, unless you want the method to <var>[[Catach]]</var> and then <var>Throw</var> the exception to the code that called the method.  For example, your method might contain code like this:
To produce a <var>DaemonLost</var> exception for a user-created method, you would issue a User Language Language <var>[[Throw]]</var> statement from within the method, and you must catch it in the code that called the method.  Because this exception is tailored to <var>daemon</var> execution by the system <var>Run</var> method, you are not likely to throw it from a user method, unless you want the method to <var>[[Catach]]</var> and then <var>Throw</var> the exception to the code that called the method.  For example, your method might contain code like this:
<p class="code">%dLost is object daemonLost
<p class="code">%dLost is object daemonLost
   [[try]] %dmn:run(%whatever)
   [[try]] %dmn:run(%whatever)
Line 74: Line 74:
end try
end try
</p>
</p>
</ol>
 
 
==See Also==
<h2>The DaemonLost methods</h2>
<ul><li>For information about catching a thrown exception, see "[[Try and Catch]]".
{{Template:List of DaemonLost methods}}
<li>The methods in this class are listed at "[[List of DaemonLost methods]]".
 
The methods in the class are described in the subsections that follow. In addition:
<ul>
<li>[[Notation conventions for methods|"Notation conventions for methods"]] has information
about the conventions followed.  
<li>[[DaemonLost methods syntax|"DaemonLost methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
</ul>
</ul>
<h2>DaemonOutput property</h2>
{{Template:DaemonLost:DaemonOutput subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns a <var>[[Stringlist|Stringlist]]</var> that contains a copy of the output of the last stream the daemon thread was running before it was lost (probably restarted). The contents of this stringlist might be useful in determining why the daemon thread was restarted.
<h4>Syntax</h4>
{{Template:DaemonLost:DaemonOutput syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%sl</th>
<td>This <var>Stringlist</var> contains a copy of the daemon thread's last output. The <var>Stringlist</var> may be empty, that is, have no items.
</td></tr>
<tr><th>%daemonLost</th>
<td>A reference to an instance of a <var>[[DaemonLost_class|DaemonLost]]</var> object.
</td></tr></table>
<h2New constructor</h2>
{{Template:DaemonLost:New subtitle}}
This constructor generates an instance of a <var>[[DaemonLost_class|DaemonLost]]</var> exception.  As shown below, the optional argument of the <var>New</var> method is a setting of the <var>[[DaemonOutput_(DaemonLost_property)|DaemonOutput]]</var> property.
<h4>Syntax</h4>
{{Template:DaemonLost:New syntax}}
<h4>Syntax terms</h4>
<table class="syntaxTable">
<tr><th>%daemonLost</th>
<td>A reference to an instance of a <var>DaemonLost</var> object.
</td></tr>
<tr><th><var>%(DaemonLost)</var></th>
<td>The class name in parentheses denotes a shared method.</td></tr>
<tr><th><var>DaemonOutput</var></th>
<td>This optional, but [[Methods#Named parameters|name required]], parameter specifies the <var>Stringlist</var> (<var class="term">stringlist</var>) to be assigned to the <var>DaemonLost</var> exception object's <var>[[DaemonOutput_(DaemonLost_property)|DaemonOutput]]</var> property when a daemon thread is lost.
</td></tr></table>
[[Category:System exception classes]]
[[Category:System exception classes]]

Revision as of 00:11, 10 May 2011


The DaemonLost exception class indicates that a daemon thread associated with a daemon object was lost, most probably because of a user restart.

The Run function of the Daemon system class is an example of a system method that automatically throws a DaemonLost exception. For more information about catching a thrown exception, see "Try and Catch".

The following example shows a "Try and Catch" of a DaemonLost exception. The daemon request is contrived to produce a user restart to demonstrate DaemonLost exception output.

begin %dmn is object daemon %sl is object stringlist %daemonLost is object daemonLost %dmn = new %sl = new text to %sl begin print 'Rosebud' end begin end text try %dmn:run(%sl) catch daemonLost to %daemonLost printText Daemon died! Its last words were: %daemonLost:daemonOutput:print end try end

The result of the preceding request shows the daemon output that was stored in the exception:

Daemon died! Its last words were: ROSEBUD

Note: It is necessary to declare the exception object in the main thread of the program, but instantiating it is taken care of by the Run Daemon method.

A request cancellation does not cause the daemon thread to go away, so it does not produce a DaemonLost exception. Consequently, using the error count on the last command may be an adequate way for your application to check for a request cancellation:

begin %dmn is object daemon %prog is object stringlist %dmn = new %prog = new text to %prog begin assert 1 eq 2 end end text try %dmn:run(%prog) if %dmn:lastCommandErrorCount then print 'Error in daemon!' end if catch daemonLost printText Caught a DaemonLost. end try end

To produce a DaemonLost exception for a user-created method, you would issue a User Language Language Throw statement from within the method, and you must catch it in the code that called the method. Because this exception is tailored to daemon execution by the system Run method, you are not likely to throw it from a user method, unless you want the method to Catach and then Throw the exception to the code that called the method. For example, your method might contain code like this:

%dLost is object daemonLost try %dmn:run(%whatever) catch daemonLost to %dlost throw %dlost end try

And the code that calls the method might contain:

%daemLost is object daemonLost try %obj:mymethod catch daemonLost to %daemLost printText Daemon lost! %daemLost:daemonOutput:print end try


The DaemonLost methods

The following are the available DaemonLost class methods.

MethodDescription
DaemonOutputStringlist copy of last output stream of lost daemon thread
NewCreate a new DaemonLost object

The methods in the class are described in the subsections that follow. In addition:


DaemonOutput property

Stringlist copy of last output stream of lost daemon thread (DaemonLost class)

This ReadOnly property returns a Stringlist that contains a copy of the output of the last stream the daemon thread was running before it was lost (probably restarted). The contents of this stringlist might be useful in determining why the daemon thread was restarted.

Syntax

%sl = daemonLost:DaemonOutput

Syntax terms

%sl This Stringlist contains a copy of the daemon thread's last output. The Stringlist may be empty, that is, have no items.
%daemonLost A reference to an instance of a DaemonLost object.

<h2New constructor

Create a new DaemonLost object (DaemonLost class) This constructor generates an instance of a DaemonLost exception. As shown below, the optional argument of the New method is a setting of the DaemonOutput property.

Syntax

%daemonLost = [%(DaemonLost):]New[( [DaemonOutput= stringlist])]

Syntax terms

%daemonLost A reference to an instance of a DaemonLost object.
%(DaemonLost) The class name in parentheses denotes a shared method.
DaemonOutput This optional, but name required, parameter specifies the Stringlist (stringlist) to be assigned to the DaemonLost exception object's DaemonOutput property when a daemon thread is lost.