Skip to main content

Nested Scopes, Outer Fault Handler Has Catchall

Nested Scopes, Outer Fault Handler Has Catchall

Suppose you have the following BPL (partially shown):

Partial BPL diagram with nested scope elements

The rest of this BPL is as follows:

Partial BPL diagram with five shapes: trace, catchall, join, trace, end

This BPL business process does the following:

  1. The first <trace> element generates the message before outer scope.

  2. The first <scope> element starts the outer scope.

  3. The next <trace> element generates the message in outer scope, before inner scope.

  4. The second <scope> element starts the inner scope.

  5. The next <trace> element generates the message in inner scope, before assign.

  6. The <assign> element tries to evaluate the expression 1/0. This attempt produces a divide-by-zero system error.

  7. Control now goes to the <faulthandlers> defined within the inner <scope>. This <scope> rectangle includes a horizontal dashed line across the middle; the area below this dashed line displays the contents of the <faulthandlers> element. In this case, a <catch> exists, but its fault value does not match the thrown fault. There is no <catchall> in the inner scope.

    Note that InterSystems IRIS skips the <trace> element that is immediately after <assign>.

  8. Control now goes to the <faulthandlers> block in the outer <scope>. No <catch> matches the fault, but there is a <catchall> block. Control goes to this <catchall>.

    If we drill into this <catchall>, we see this:

    BPL diagram with the following shapes in order: start, trace, end

  9. Within this <catchall>, the <trace> element generates the message in outer scope, catchall.

  10. The outer <scope> ends.

  11. The last <trace> element generates the message after outer scope.

Event Log Entries

The corresponding Event Log entries look like this:

Event log with entries for inner and outer scope elements

XData for This BPL

This BPL is defined by the following XData block:

XData BPL
{
<process language='objectscript'
         request='Test.Scope.Request'
         response='Test.Scope.Response' >
  <sequence>
    <trace value='"before outer scope"'/>
    <scope>
      <trace value='"in outer scope, before inner scope"'/>
      <scope>
        <trace value='"in inner scope, before assign"'/>
        <assign property="SomeProperty" value="1/0"/>
        <trace value='"in inner scope, after assign"'/>
        <faulthandlers>
          <catch fault='"MismatchedFault"'>
            <trace value=
              '"In catch faulthandler for &apos;MismatchedFault&apos;"'/>
          </catch>
        </faulthandlers>
      </scope>
      <trace value='"in outer scope, after inner scope"'/>
      <faulthandlers>
        <catchall>
          <trace value='"in outer scope, catchall"'/>
        </catchall>
      </faulthandlers>
    </scope>
    <trace value='"after outer scope"'/>
  </sequence>
</process>
}
FeedbackOpens in a new tab