makeError()

The function returns an error (in an errClass variable) and shows an error message or an information message in accordance with the _errors.cat error message catalog in <wincc_oa_path>/msg/<lang>or an error or information message according to your own error catalog. If you use the first alternative in the example further on, you have to use the _errors.cat catalog. The second alternative allows you to use your own catalog file with your own error or information messages. In this way, the function can be used to handle own errors and to display own error and information messages.

Synopsis

errClass makeError( [bit32 bit[, int prio[, int type[, int code[, string dp [, int man[, int user[, string note1[, string note2[, string note3]]]]]]]]]]]);

errClass makeError( string cat, int prio, int type, int code [,string note1 [,string note2 [,note3]]]);

Parameters

Parameters value Meaning
cat

Catalog file without the extension cat, for example, "myErrors". The file is either the _errors.cat file located in <wincc_oa_path>/msg/<lang> or your own catalog file located in your project path <proj_path>/msg/<lang>. If you define your own error catalog, the error numbers in your catalog file have to be 5-digit numbers starting with 0, for example, 00001 (see also the example at the end of this page). Note also that if you have a multilingual project, the catalog file has to be located in each project language directory in <proj_path>/msg/<lang>.

If you pass an empty string, the catalog _errors.cat in <wincc_oa_path>/msg/<lang>will be used.

bit Internal, should be 0
prio Indicates the importance of the error.
PRIO_FATAL Program is terminated
PRIO_SEVERE Rescue measures required
PRIO_WARNING Information for the user
PRIO_INFO Information for the user for flow monitoring
type
ERR_IMPL Implementation error
ERR_PARAM Configuration error
ERR_SYSTEM System error
ERR_CONTROL

Control runtime error

Output without stack trace

ERR_REDUNDANCY Redundancy error
code Sequence number from the _errors.cat file in <wincc_oa_path>/msg/<lang> or number from your own catalog file in <proj_pfad>/msg/<lang>.
man Manager where the error has been triggered. You can get an integer that corresponds to the manager identifier with the function convManIdToInt(). See also the second example at the end of this page. The manager identifier consists of replica (R), system number (S), manager type (T) and number (N) in the following format 0xRRSSTTNN.
user Trigger of the error
dp Name of the data point where the error occurred
note1-3 Any textual details, optional parameter

Return value

An error class. The returned error can be printed with the function throwError (see example below).

Error

Description

The function makeError is used to catch an error and show an error or information message from an error catalog. The error message or information will be shown through the throwError function.

Example

This example obtains a data point value with the dpGet function and checks if the get value is within a specified value range. The check will be made by means of a switch or case structure. If the value is not within the value range, a separate information message from your own catalog file will be displayed. The error (value is not within the value range) is caught with the makeErrorfunction and the information message is shown through thethrowErrorfunction. The error catalog used in this function is shown in the figure below.

main()
{
  string cat, note1; //Variable definitions for the makeError
  function
  int prio,typ,co, dpG1;
  cat ="myError"; /* Definition of the catalog. The cat extension
  is not used. Only the name of the file. */
  prio=PRIO_INFO; /* Constant which defines the importance of the
  error/of the information */
  typ =ERR_PARAM; //Type of the error
  co = 2; /* Sequence number of the information message from the
  own catalog "myError" */
  note1 = "The value should be between 2.0-2.2"; /* Additional
  information that is shown. Is an optional parameter */
  errClass retError; //errClass variable for the makeError
  function
  string dp1 = "ExampleDP_Arg1.:_original.._value";
  float answ;
  DebugN("dpGet");
  dpG1=dpGet(dp1, answ);
  switch(answ)
  {
    case 2.0: DebugN("Value within the value range:");
    break;
    case 2.1: DebugN("Value within the value range:");
    break;
    case 2.2: DebugN("Value within the value range:");
    break;
    default:
    DebugN("make error");
    retError=makeError(cat,prio,typ,co,note1); /* Function call.
    Catches the 
    error */
    DebugN("throwError");
    throwError(retError); //Shows the information message
  }
}

Figure: myError.cat

You can also use the other alternative of the makeError function. This alternative, however, only allows using the _errors.cat catalog in <wincc_oa_path>/msg/<lang>.

main()
{
  string cat, note1; //Variable definitions for the makeError
  function
  bit32 bit=0;
  int prio,typ,co, dpG1,man,user;
  user =0; //The WinCC OA user with the user ID
  0
  man=convManIdToInt(UI_MAN, 1); /* The manager Number of user
  interface manager */
  prio=PRIO_INFO; /* Constant which defines the importance of the
  error/of the information */
  typ =ERR_PARAM; //Type of the error
  co = 29; /* Sequence number of the information message from the
  catalog "_errors.cat" */
  note1 = "The value should be between 2.0-2.2"; /* Additional
  information that is shown. Is an optional parameter */
  errClass retError; /* errClass variable for the makeError
  function */
  string dp1 = "ExampleDP_Arg1.:_original.._value";
  float answ;
  DebugN("dpGet");
  dpG1=dpGet(dp1, answ);
  switch(answ)
  {
    case 2.0: DebugN("Value within the value range:");
    break;
    case 2.1: DebugN("Value within the value range:");
    break;
    case 2.2: DebugN("Value within the value range:");
    break;
    default:
    DebugN("make error");
    retError=makeError(bit, prio, typ,co,dp1, man,user, note1); /*
    Function
    call. Catches the error */
    DebugN("throwError");
    throwError(retError); //Shows the information message
  }
}

Assignment

Error

Availability

CTRL