ItemNotFound class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (tags and edits)
mNo edit summary
Line 1: Line 1:
<!-- ItemNotFound class -->
<!-- ItemNotFound class -->
__NOTOC__
An <var>ItemNotFound</var> exception indicates that a collection object search located no collection items that satisfy the selection criterion specified in the collection method that invoked the search.
An <var>ItemNotFound</var> exception indicates that a collection object search located no collection items that satisfy the selection criterion specified in the collection method that invoked the search.
There are several methods for [[Collections#Searching a collection|"searching a collection"]], but only those that return a single found item produce an <var>ItemNotFound</var> exception.
There are several methods for [[Collections#Searching a collection|"searching a collection"]], but only those that return a single found item produce an <var>ItemNotFound</var> exception.
Line 31: Line 32:
</p>
</p>
   
   
The methods in this class are listed at "[[List of ItemNotFound methods]]".
The <var>ItemNotFound</var> class is available as of <var class="product">[[Category:System exception classes]]</var> version 7.6.
 
 
<h2>The ItemNotFound methods</h2>
{{Template:List of ItemNotFound 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>[[ItemNotFound methods syntax|"ItemNotFound methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
</ul>
 
 
<h2>Code property</h2>


The <var>ItemNotFound</var> class is available as of <var class="product">[[Category:System exception classes]]</var> version 7.6.
[[Category:System exception classes]]
[[Category:System exception classes]]

Revision as of 16:12, 10 May 2011


An ItemNotFound exception indicates that a collection object search located no collection items that satisfy the selection criterion specified in the collection method that invoked the search. There are several methods for "searching a collection", but only those that return a single found item produce an ItemNotFound exception.

This exception class has no properties. It is simply a notification that a valid search found no items that met the selection criterion.

The class's only method is the New constructor, which you would typically use with a User Language Throw statement to produce an ItemNotFound exception. For example:

throw %(itemNotFound):new

When working with the collection searching methods, remember that an exception is thrown only if there is a catcher for the exception. For example, if you expect one or no matches from your search, you might specify a block like the following:

try %terminationInfo = - %terminationList:findNextItem (eq(custId, %custid) ... process the termination info catch itemNotFound end try

On the other hand, if you always expect a match, you might want a program crash to result if you are wrong about the match, so you could leave out a Try/Catch.

The Try/Catch approach is slightly more efficient than a test for a zero result. Try generates no quads other than the branch around the catch block if the search succeeds. And in fact, you could put a Try around a loop and use the ItemNotFound exception to exit the loop:

%i = 0 try repeat forever %i = %colla:findNextItemNumber(<criterion>), start=%i) %obj = %colla(%i) ... process the object end repeat catch itemNotFound end try

The ItemNotFound class is available as of version 7.6.


The ItemNotFound methods

The following are the available ItemNotFound class methods.

MethodDescription
NewCreate a new ItemNotFound object

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


Code property