FRM
v1.4.2

std
Script emos_std_err_lib

CompiledModule
  |
  +--emos_std_err_lib

This library implements an interface to descriptions of WinRunner errors. All information about error codes ant the corresponding descriptions are maintained in Excel table "default.xls". To keep this library up to date some manual work is necessary. Our approach is two-fold:

By default "all codes" are activated. However you may change this by setting the other sheet as default (note that the file is read-only).

Language support

Note that this library supports two languages so far: English and German. We use codes "EN" and "DE" respectively. We have decided to keep our own list of language codes (see err_get_supproted_languages()) because we cannot rely on WinRunner's undocumented features such as get_lang() function (which returns "DEU" for German and God knows what for other environments).

You are welcome to add additional languages. Please inform us about this so we can merge your language into our distribution.

Typical usage

This library is automatically loaded with EMOS Framework. By default english texts are loaded. You would normally change this setting in your startup test, e.g.
	    err_set_language( "DE" );
 
To print formatted error descriptions you could do following in your code:
	    rc = set_window( "some non-existing window" );
	    if ( rc != E_OK )
	    {
	    	print( err_perror( rc ) );
	    	tl_step( "Argh!", FAIL, "Have enough for today." );
	    	treturn rc;
	    }
 

Acknowledgements

We would especially like to thank Michael Skobowsky from DAT (mailto:Michael.Skobowsky@dat.de) for his German translation and for all his enthusiastic support and ideas.

Tsl
emos_std_err_lib.tsl

Function Summary
 String err_get_error_code(in errNr)
          Returns the error code as text for the given error number, e.g.
 String err_get_error_desc(in errNr, in lang)
          Returns the error description for the given error number and the langauge code.
 String err_get_language()
          Returns the code of the default language.
 String err_get_supproted_languages()
          Returns the comma-separated list of the supported languages for error descriptions.
protected  String err_init()
          Initialises the internal data structures from external table "default.xls".
 String err_is_error(in errNr)
          Returns TRUE if given errNr is a known error code.
 String err_perror(in errNr)
          Returns formatted error message, e.g. "[-10001] General error occurred.
 String err_set_language(in lang)
          Sets the default language to the given lang code.
 

Function Detail

err_init

protected String err_init()
Initialises the internal data structures from external table "default.xls".

Returns:
E_OK if initialisation OK, otherwise failure.

err_get_supproted_languages

public String err_get_supproted_languages()
Returns the comma-separated list of the supported languages for error descriptions.


err_set_language

public String err_set_language(in lang)
Sets the default language to the given lang code. This function returns the code of the new default language. If invalid language code is given, no change is made and the old default code is returned. The available language codes are returned via err_get_supported_languages().

Parameters:
lang - language code

err_get_language

public String err_get_language()
Returns the code of the default language.


err_is_error

public String err_is_error(in errNr)
Returns TRUE if given errNr is a known error code. Otherwise FALSE is returned.

Parameters:
errNr - error number

err_get_error_desc

public String err_get_error_desc(in errNr,
                                 in lang)
Returns the error description for the given error number and the langauge code. If no language code was given, the default language is taken. For non-existing error numbers an empty string is returned.

Parameters:
errNr - error number

err_get_error_code

public String err_get_error_code(in errNr)
Returns the error code as text for the given error number, e.g. "E_GENERAL_ERROR". For non-existing error numbers an empty string is returned.

Parameters:
errNr - error number

err_perror

public String err_perror(in errNr)
Returns formatted error message, e.g. "[-10001] General error occurred. (E_GENERAL_ERROR)". The message is also printed out via debug_msg().

NOTE: This function only supports the default language.

Parameters:
errNr - error number

FRM
v1.4.2