Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Trapping Errors in Queries

A-Stack Error handling mechanism can be used to trap errors All TQL exceptions are caught by the TQL facet itself and reported in query/attribute status. TQL exceptions are not passed to error handler and instead we should check the status instead. In the example below we check for Find status value and make changes to the response. 

Step to Check for Find Status is:

Code Block
languagexml
themeEmacs
titleError Handling in Queries
linenumberstrue
<If Condition="$Response.Message.Value.Find/Status eq 'Error'">
</If>


Code Block
languagexml
themeEmacs
titleError Handling in Queries
linenumberstrue
<Query>
  <Find Format="Version">
    <VendorInfo1>
      <vendorId>
        <NE>
        </NE>
      </vendorId>
    </VendorInfo1>
   <SetLocalData key="ErrorHandler</Find>
  <If Condition="$Response.Message.Value.Find/Status eq 'Error'">
    <Value><Then>
      <SetResponseData><AddResponseData>
        <Key>
          Message.Value.Error.Message
        </Key>
        <Value>
          [:$Error$Response.Message.Value.Find.Error:]
        </Value>
      </SetResponseData>AddResponseData>
      <AddResponseData>
        <Key>
          Message.Value.Error.Code
        </Key>
        <Value>
          1002
        </Value>
      </SetLocalData>AddResponseData>
      <SetResponseData>
        <Key>
      <Find Format="Version">   Message.Value.Find
 <VendorInfo1>       <vendorId></Key>
        <NE><Value>
        </NE>Value>
      </vendorId>SetResponseData>
    </VendorInfo1>Then>
  </Find>If>
</Query>