Package com.dassault_systemes.catjsystem

   
Class CATError

 
Class Hierarchy
java.lang.Object
  |
  +-java.lang.Throwable
        |
        +-java.lang.Exception
              |
              +-com.dassault_systemes.catjsystem.CATError
Class Location

Framework : CATJSystem

Module : CATJSystem

Class Description

public class CATError

An object that enables error handling with internationalization capabilities.

This object can be used to wrap low level errors or exceptions that occur within the application.

Error messages can be defined inside a message catalog using one of the combination described below:

  1. SYSTEM_ERR001 = "Error message";
  2. SYSTEM_ERR001.Request = "Error request message";
    SYSTEM_ERR001.Diagnostic = "Error diagnostic message";
    SYSTEM_ERR001.Advice = "Error advice message";

When using the second approach combined with a call to the getNLSMessage(CATSession) method, the '.Request', '.Diagnostic' and '.Advice' messages are computed together and split on different lines. They can still be accessed separately using the following methods: getNLSRequest(CATSession), getNLSDiagnostic(CATSession) and getNLSAdvice(CATSession).

Parameters can be defined inside message strings, and their values can be later specified in the code using the following method: setParameter(int, String).

Here follows an example of parameter definition inside a message catalog:
SYSTEM_ERR001.Request = "Error while loading file /p1";

Before displaying or throwing the error message described above, the parameter value should be set programmatically as described below:
error.setParameter(1, fileName);

See Also:
CATMessageCatalog
CATSession
Field Summary
public static final int ERROR
Severity flag for error messages.
public static final int INFO
Severity flag for informative messages.
public static final int WARNING
Severity flag for warning messages.

Constructor Summary
CATError(String iMsgCatalog, String iMsgId)
Initializes a new instance with a given error identifier and a given message.
CATError(Throwable iFatherError, String iMsgCatalog, String iMsgId)
Initializes a new instance with a given error identifier and a given message.

Method Summary
public final String getComponent()
Returns the name of the message catalog associated with the current instance.
public final Throwable getFatherError()
Returns the source error or exception, if any.
public final String getMsgId()
Returns the error message identifier.
public final String getNLSAdvice(CATSession iSession)
Returns the NLS message for "Advice", replacing parameters with set values.
public final String getNLSDiagnostic(CATSession iSession)
Returns the NLS message for "Diagnostic", replacing parameters with the values specified, if any.
public final String getNLSMessage(CATSession iSession)
Returns the error message in the current locale.
public final String getNLSRequest(CATSession iSession)
Returns the NLS message for "Request", replacing parameters with the values specified, if any.
public final void setParameter(int iIndex, String iValue)
Provides a parameter value that will be used when computing the error message (see class documentation for details on this topic).


Field Detail

ERROR

    public static final int ERROR
Severity flag for error messages.


INFO

    public static final int INFO
Severity flag for informative messages.


WARNING

    public static final int WARNING
Severity flag for warning messages.


Constructor Detail

CATError

    CATError(String iMsgCatalog, String iMsgId)

Initializes a new instance with a given error identifier and a given message.

Parameters:
iMsgCatalog
the message catalog name in which the message is located
iMsgId
the message identifier (it must be referenced into the catalog file as a key)

CATError

    CATError(Throwable iFatherError, String iMsgCatalog, String iMsgId)

Initializes a new instance with a given error identifier and a given message. This constructor can be used to provide the source error or exception that may have been caught and wrap it into the current instance.

Parameters:
iFatherError
the source error or exception that has been caught
iMsgCatalog
the message catalog in which the message is located
iMsgId
the message identifier (it must be referenced into the catalog file as a key value)

Method Detail

getComponent

    public final String getComponent()

Returns the name of the message catalog associated with the current instance. The name of this catalog is considered to describe the name of the source 'component' where the error occured. It is a logical concept and will only be accurate if the name of the message catalog has been set accordingly.

Return:
the name of the message catalog associated with the current instance.

getFatherError

    public final Throwable getFatherError()

Returns the source error or exception, if any.

Return:
the source error, null if not available.

getMsgId

    public final String getMsgId()

Returns the error message identifier.

Return:
the error message identifier (it must be referenced into the catalog file as a key value).

getNLSAdvice

    public final String getNLSAdvice(CATSession iSession)

Returns the NLS message for "Advice", replacing parameters with set values.

Parameters:
iSession
the current session used to retrieved the current locale.
Return:

getNLSDiagnostic

    public final String getNLSDiagnostic(CATSession iSession)

Returns the NLS message for "Diagnostic", replacing parameters with the values specified, if any.

Parameters:
iSession
the current session used to retrieved the current locale.
Return:

getNLSMessage

    public final String getNLSMessage(CATSession iSession)

Returns the error message in the current locale. The message is split into several lines if either the '.Request', '.Diagnostic' or '.Advice' suffixes have been appended to the message identifier specified inside the input message catalog (see class documentation for details on this topic).

Parameters:
iSession
the current session used to retrieved the current locale.
Return:
the translated message according to the current locale.

getNLSRequest

    public final String getNLSRequest(CATSession iSession)

Returns the NLS message for "Request", replacing parameters with the values specified, if any.

Parameters:
iSession
the current session used to retrieved the current locale.
Return:

setParameter

    public final void setParameter(int iIndex, String iValue)

Provides a parameter value that will be used when computing the error message (see class documentation for details on this topic).

Parameters:
iIndex
the parameter index (must match the value specified in the message catalog)
iValue
the parameter value


Copyright © 2000, Dassault Systèmes. All rights reserved