Show TOC Start of Content Area

Function documentation The Program Flow for a Location  Locate the document in its SAP Library structure

Use

This is only available in a location. Tracing the flow of a program is a common practice: entering, exiting, throwing, assertion.

      entering() – outputs a default message (“Entering Method” with Path severity) indicating that it is entering a source block.

This graphic is explained in the accompanying text

Always paired up with the exiting() method.

The entering() Method

Method

Description

entering()

Entering a source block in general.

entering(String subloc)

Specifies the method name in subloc.

entering(Object[] args)

A general source block with arguments: “Entering method with <args>”.

entering(String subloc, Object[] args)

The same as the previous one, but with a specific method name.

 

      exiting() – outputs a default message (“Exiting Method” with Path severity), indicating that it is leaving a source block.

This graphic is explained in the accompanying text

Always paired up with the entering() method.

The exiting() Method

Method

Description

exiting()

Exiting a source block in general. As long as the method name (subloc) is specified in ‘entering’, it is no longer necessary to provide a subloc as argument. The result are presented in the sample code snippet below.

exiting(String subloc)    //DEPRECATED

Specifies the method name in subloc

exiting(Object res)

A general source block with result: “Exiting method with <res>”.

exiting(String subloc, Object res)

The same as the previous one, but with a specific method name.

 

To reiterate, refer to the sample code with method announce(Object o):

This graphic is explained in the accompanying text

Always log the entering and exiting methods together.

public void announce(Object o) {

   String method = "announce(java.lang.Object)";

   loc.entering(method);

   try {

   } catch (Exception e) {

   }

   loc.exiting();

}

 

The potential output, assuming the simplest case with ConsoleLog and default TraceFormatter, is:

May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main] Path: Entering method

May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main] Path: Exiting method

 

      throwing() – a warning message (“Throwing …”) indicating that the source block is about to throw an exception.

The throwing() Method

Method

Description

throwing(Throwable exc)

Throws the exception exc.

Throwing(String subloc, Throwable exc)

The same as the previous one, but with a specific method name.

 

      assertion() – to test a condition and output an error message, normally with the assertion included (“Assertion failed: <assertion test>”) when the evaluation is false.

The assertion() Method

Method

Description

assertion(Boolean assertion, String desc)

Evaluates the assertion. If false, prints desc with the default message: “Assertion failed: <desc>”, where <desc> is the assertion test itself, for example 5 > 3.

assertion(String subloc,  Boolean assertion, String desc)

The same as the previous one, but with a specific method name.

 

To reiterate, refer to the sample code with method announce(Object o):

This graphic is explained in the accompanying text

public void announce(Object o) {

   String method = "announce(java.lang.Object)";

   loc.assertion(method, 5 < 3,"Stupid comparison“);

    try {

    }

    catch (Exception e) {

      loc.throwing(method, e);

    }

}

 

The potential output, assuming the simplest case with ConsoleLog and default TraceFormatter, is:

May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main]   

                     Error: Assertion failed: Stupid comparison

May 3, 2001 6:54:18 PM com.sap.fooPackage.Node.announce [main]   

                                Warning: Throwing java.io.FileNotFoundException:                

                                         C:\Not_Exist\zzzzz.log (The system cannot find the path specified)

 

See also:

The Master Gate

 

End of Content Area