Friday June 21, 2024

      SteelArrow Basics
      SteelArrow Tags
  SteelArrow Functions
  SteelArrow Objects
  Advanced Topics
  WAS Overview
  Code Samples
  Site Search

Get SteelArrow!     
SteelArrow supports full exception handling. By supporting exception handling, error flow control can be completely configured by the developer. If you are a C++ or Java developer, you will be right at home with this supported functionality.

With exception handling, certain operations can be tried (with TRY), and any errors that may be generated can be caught (with CATCH). As well, user information errors can be thrown (with THROW).

The below code snippet shows an example of using TRY/CATCH:

<SATRY> <!--- TRY something --->
      INSERT INTO table(col1,col2)
        VALUES( '#PARAM.value1#', '#PARAM.value2#' )

<SACATCH ERRTYPE="DATABASE">    There was a database error!<BR> </SACATCH>
<SACATCH ERRTYPE="SECURITY">    There was a security error!<BR> </SACATCH>

The above example shows how a DATABASE and SECURITY error can be caught before normal error processing results (ie. standard error page would be shown by default).

Exceptions types that can be caught include:
DATABASE Errors generated based on a bad query sent to a datasource.
SECURITY Errors generated due to security restrictions.
PARSER Parsing errors; should never be seen.
SCRIPT Incorrectly formed scripts.
An example would be a missing </SAIF> in an <SAIF> block.
USER Error messages generated with a THROW.
ALL Any of the error types described above.


Generated errors that are caught are stored in the ERROR table, and can be accessed the same way as any other variable. As well, the context of the error is maintained. This means that the CGI, PARAM or any other SteelArrow table can be queried to determine its state at the time of the error.

The ERROR table will contain the following:
FILE Script that generated the error.
LINE Line number corresponding to the error.
ERRTYPE Type of error; one of the types listed above.
MESSAGE Error message.
DATA The data that caused the error to be generated;
usually the corresponding SteelArrow tag.


The below code is an example that uses the THROW tag;

<SATRY> <!--- TRY something --->
   <SAIF COND=UserName .ne. "test">
      <SATHROW MESSAGE="You are not the test user.">
<!--- will be executed if UserName not equal       to "test" --> <SACATCH ERRTYPE="USER">    <!--- UserName was not "test" --->    <SAOUTPUT VALUE=ERROR.MESSAGE> </SACATCH>
<!--- Other processing follows --->

Copyright © 1998-2004 Tomahawk Technologies Inc.
Privacy Policy