Update README.md
[deliverable/titan.core.git] / help / info / catch.html
CommitLineData
970ed795
EL
1<!--
2 Copyright (c) 2000-2014 Ericsson Telecom AB
3
4 All rights reserved. This program and the accompanying materials
5 are made available under the terms of the Eclipse Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/epl-v10.html
8 -->
9<html>
10<head>
11<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12<meta http-equiv="Content-Language" content="en-us">
13<title>catch</title>
14</head>
15<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258">
16<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top>
17 <tr>
18 <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td>
19 </tr>
20</table>
21<table border="0" align="right" cellpadding="0" cellspacing="0">
22 <tr>
23 <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td>
24 <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td>
25 <td><a href="case.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td>
26 <td><a href="char.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td>
27 </tr>
28</table>
29<p><br clear="all">
30</p>
31<hr>
32<h1>catch</h1>
33<hr align="left" width="75%">
34<p>The operation belongs to the family of procedure-based communication operations. It is used to handle exceptions from a previously called procedure.
35<ul>
36 <li>The operation can be used on connected procedure-based (or mixed) ports.</li>
37 <li>In case of multiple connections the operation may be restricted to one communication partner.</li>
38 <li><a href="timeout.html">Timeout</a> constitutes a special case of exception.</li>
39</ul>
40<p>Related keywords:</p>
41<ul>
42 <li><a href="address.html"><b><font face="Courier New" color="#003258" size="4">address</font></b></a></li>
43 <li><a href="create.html"><b><font face="Courier New" color="#003258" size="4">create</font></b></a></li>
44 <li><a href="from.html"><b><font face="Courier New" color="#003258" size="4">from</font></b></a></li>
45 <li><a href="modifies.html"><b><font face="Courier New" color="#003258" size="4">modifies</font></b></a></li>
46 <li><a href="sender.html"><b><font face="Courier New" color="#003258" size="4">sender</font></b></a> &nbsp;</li>
47 <li><a href="signature.html"><b><font face="Courier New" color="#003258" size="4">signature</font></b></a></li>
48 <li><a href="system.html"><b><font face="Courier New" color="#003258" size="4">system</font></b></a></li>
49 <li><a href="value.html"><b><font face="Courier New" color="#003258" size="4">value</font></b></a></li>
50</ul>
51<hr align="left" width="50%">
52<div align="center">
53<center>
54<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4">
55 <tr>
56 <td width="100%">
57 <h3 align="center"><i>port_reference</i><font face="Courier New" color="#003258" size="5"><b>.catch </b></font> [ <font face="Courier New" color="#003258" size="5"><b> (</b></font><i>signature_reference</i><font
58 face="Courier New" color="#003258" size="5"><b>,</b></font><i> template_instance&nbsp; </i><font face="Courier New" color="#003258" size="5"><b>)</b></font> ] [ <font face="Courier New"
59 color="#003258" size="5"><b>from </b></font><i>address_reference</i> ] [ <font face="Courier New" color="#003258" size="5"><b>-&gt; </b></font><i>assignment_part</i> ]<font face="Courier New"
60 color="#003258" size="5"><b>;</b></font> &nbsp;</h3>
61 </td>
62 </tr>
63</table>
64</center>
65</div>
66<ul>
67 <li>
68 <p><i> port_reference</i> points out the port where the exception is raised.</p>
69 <ul>
70 <li>
71 <p>the keywords <b><font face="Courier New" color="#003258" size="4">any port</font> </b> may be used to indicate that exceptions will be accepted at any port (see the <a href="#Example 4:">example
72 4</a>).</p>
73 </li>
74 </ul>
75 </li>
76 <li>
77 <p>The <b><font face="Courier New" color="#003258" size="4">catch</font> </b>keyword introduces the exception capture.</p>
78 </li>
79 <li>
80 <p><i>signature_reference</i> points out the signature where the exception is defined</p>
81 </li>
82 <li>
83 <p><i>template_instance</i> may be one of the following&nbsp; (<a href="#Example 5">when omitted</a>, any valid exception will be caught):</p>
84 <ul>
85 <li>in-line signature template (see the <a href="#Example 1">example1</a>);</li>
86 <li>a receiving template (see the <a href="#Example 2">example 2</a>);</li>
87 <li>a modified template (see the <a href="#Example 3">example 3</a>);<br>
88 &nbsp;</li>
89 </ul>
90 </li>
91 <table border="0" width="100%" bgcolor="#C9C2BB" cellpadding="4">
92 <tr>
93 <td width="100%">
94 <p><u>TITAN specific restriction compared to the standard:</u></p>
95 <ul>
96 <li>
97 <p>&nbsp;modified template is not implemented. When encountered in the TTCN-3 program, an error message will be generated.</p>
98 </li>
99 </ul>
100 </td>
101 </tr>
102 </table>
103 <li>
104 <p>The optional <b><font face="Courier New" color="#003258" size="4">from</font> </b> keyword&nbsp; is used when a port is connected to several entities and restriction to one communication
105 partner is required.</p>
106 </li>
107 <li>
108 <p><i>address_reference</i> is one of the following:</p>
109 <ul>
110 <li>a component reference (cf. <a href="create.html"><b><font face="Courier New" color="#003258" size="4">create</font></b></a>)&nbsp; or the keyword <a href="system.html"
111 target="_blank"><b><font face="Courier New" color="#003258" size="4">system</font></b></a>, in case of one-to-many connections.</li>
112 <li>
113 <p>an address reference (cf. <a href="address.html"><b><font face="Courier New" color="#003258" size="4">address</font></b></a>) , when there are several entities within the
114 system under test.</p>
115 </li>
116 </ul>
117 </li>
118 <li>
119 <p><i>assignment_part</i> is one or both of the following:</p>
120 <ul>
121 <li>the <a href="sender.html"><b><font face="Courier New" color="#003258" size="4">sender</font></b></a> keyword followed by a variable of <a href="address.html"
122 target="_blank"><b><font face="Courier New" color="#003258" size="4">address</font></b></a> or&nbsp; <a href="component.html"><b><font face="Courier New" color="#003258"
123 size="4">component</font></b></a> type to store the address of the sender (see the <a href="#Example 2">example 2</a>).</li>
124 <li>the <a href="value.html"><b><font face="Courier New" color="#003258" size="4">value</font></b></a> keyword followed by a variable of the appropriate type to store the
125 exception value (see the <a href="#Example 3">example 3</a>).</li>
126 </ul>
127 </li>
128</ul>
129<hr align="left" width="50%">
130<p><a name="Example 1">Example 1</a>: in-line signature template&nbsp;
131<p><font face="Courier New">signature S_MyProcedure (inout integer pl_MyPar91) exception (integer, float);<br>
132<br>
133MujPort_PCO.catch(S_MyProcedure, integer:14 .. 143) from system;</font>
134<p>The signature S_MyProcedure is defined in the first line. It has one parameter (pl_MyPar91, pl_MyPar2 and pl_MyPar3). In the second line, an exception is caught at&nbsp; the port MujPort_PCO.
135The port is connected to several components, but communication is restricted to one component, here to the test system interface. Exceptions with the integer code between 14 and 143 are caught.</p>
136<hr align="left" width="50%">
137<p><a name="Example 2">Example 2</a>: signature template and address redirect</p>
138<p><font face="Courier New">template IntegerFloatRecord tr_ExTemplate&nbsp; := {<br>
139&nbsp;&nbsp;&nbsp;field1 := 1 .. 6,<br>
140&nbsp;&nbsp;&nbsp;field2 := 0.0 .. infinity<br>
141}</font>
142<p><font face="Courier New">MujPort_PCO.catch (S_MyProcedure, tr_ExTemplate) -&gt; sender v_address;</font></p>
143<p>The parameterized template (tr_ExTemplate) catches exceptions where the integer parameter lies between one and six, and the floating point value parameter greater than zero. The address of the
144component raising the exception is stored in the variable v_address.</p>
145<hr align="left" width="50%">
146<p><a name="Example 3">Example 3</a>: modified signature template and value redirect</p>
147<p><font face="Courier New">MujPort_PCO.catch (modifies tr_ExTemplate := {field1 := 6}) -&gt; value v_Exc;</font></p>
148<p>The template defined in example 2 is modified. The response is now accepted when the integer parameter equals six. The returned exception value is stored in the variable v_Exc.</p>
149<hr align="left" width="50%">
150<p><a name="Example 4:">Example 4:</a> receive on any port</p>
151<p><font face="Courier New">any port.catch (tr_ExTemplate);</font></p>
152<p>The exception matching the template tr_ExTemplate will be accepted on any port.</p>
153<hr align="left" width="50%">
154<p><a name="Example 5">Example 5</a>: Accepting any exception</p>
155<p><font face="Courier New">MujPort_PCO.catch;</font></p>
156<p>Removes the top exception from MujPort_PCO.</p>
157<hr align="left" width="50%">
158<p><a name="Example 6">Example 6</a>: Catching a timeout</p>
159<p><font face="Courier New">MujPort_PCO.catch(timeout);</font></p>
160<p>The exception caused by the timeout at the port MujPort_PCO is caught.</p>
161<hr align="left" width="25%">
162<hr align="left" width="25%">
163<p><a HREF="BNF.html#catchstatement">BNF definition</a> of <font face="Courier New"> catch</font></p>
164</body>
165</html>
This page took 0.040934 seconds and 5 git commands to generate.