norsys.netica
Class NeticaError

java.lang.Object
  |
  +--norsys.netica.NeticaError

public class NeticaError
extends java.lang.Object

A java.lang.Error that holds extra information when Netica reports an error for some attempted operation.

Since:
2.08

Field Summary
static int ERROR_ERR
          Event occurred at "error" level - operation not properly finished, but no internal inconsistencies (e.g., user error, didn't finish process).
static int FROM_DEVELOPER_CND
          Your program indicated the error.
static int FROM_WRAPPER_CND
          The error did not occur within Netica itself, but in the JAVA API wrapper layer.
static int INCONS_FINDING_CND
          Inconsistent finding (only).
static int NOTHING_ERR
          Not anything (false alarm or "this is a test").
static int NOTICE_ERR
          Notice of something unusual.
static int OUT_OF_MEMORY_CND
          System did not have enough memory to complete operation.
static int REPORT_ERR
          Not an error, but a report of success.
static int USER_ABORTED_CND
          User halted the function before it completed (not possible when using a Netica API version without the user interface)

static int WARNING_ERR
          Event occurred at "warning" level - safe to proceed (e.g., user error, recovered okay).
static int XXX_ERR
          Internal error, things left inconsistent - continuing could crash system.
 
Method Summary
 int getIdNumber()
          Returns the ERROR_NUMBER identifying this error.
 java.lang.String getMessage()
          Given a report of an error, this returns a message explaining the error.
 int getSeverity()
          Returns the ERROR_SEVERITY level of this error (one of NOTHING_ERR, REPORT_ERR, NOTICE_ERR, WARNING_ERR, ERROR_ERR, or XXX_ERR).
static java.util.Vector getWarnings(int severity)
          Retrieve and clear (remove) all messages from the current default Environment that are below the severity level for generating a NeticaException.
 boolean isInCategory(int errcnd)
          Returns a boolean to indicate whether this error was caused by the condition errcnd.
 java.lang.String toString()
          Returns a readable string representation of this error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOTHING_ERR

public static final int NOTHING_ERR
Not anything (false alarm or "this is a test").


REPORT_ERR

public static final int REPORT_ERR
Not an error, but a report of success.


NOTICE_ERR

public static final int NOTICE_ERR
Notice of something unusual.


WARNING_ERR

public static final int WARNING_ERR
Event occurred at "warning" level - safe to proceed (e.g., user error, recovered okay).


ERROR_ERR

public static final int ERROR_ERR
Event occurred at "error" level - operation not properly finished, but no internal inconsistencies (e.g., user error, didn't finish process).


XXX_ERR

public static final int XXX_ERR
Internal error, things left inconsistent - continuing could crash system.


OUT_OF_MEMORY_CND

public static final int OUT_OF_MEMORY_CND
System did not have enough memory to complete operation.


USER_ABORTED_CND

public static final int USER_ABORTED_CND
User halted the function before it completed (not possible when using a Netica API version without the user interface)


FROM_WRAPPER_CND

public static final int FROM_WRAPPER_CND
The error did not occur within Netica itself, but in the JAVA API wrapper layer.


FROM_DEVELOPER_CND

public static final int FROM_DEVELOPER_CND
Your program indicated the error.


INCONS_FINDING_CND

public static final int INCONS_FINDING_CND
Inconsistent finding (only).

Method Detail

getIdNumber

public int getIdNumber()
Returns the ERROR_NUMBER identifying this error.

Version:
This function is available in all versions.
In the C Version of the API, this function is called ErrorNumber_ns.
See Also:
isInCategory  Returns a more general categorization of the error
getMessage  Returns a complete error message


getSeverity

public int getSeverity()
Returns the ERROR_SEVERITY level of this error (one of NOTHING_ERR, REPORT_ERR, NOTICE_ERR, WARNING_ERR, ERROR_ERR, or XXX_ERR).

This returns an indicator of how serious the error is.

These are some of the values, in order from least to most serious, that may be returned:
NOTHING_ERR  Not anything (nothing to report)
REPORT_ERR  Not an error, but a report of success
NOTICE_ERR  Notice of something unusual
WARNING_ERR  Event occurred at "warning" level - requested operation was completed,
but results are suspect in some way
ERROR_ERR  Event occurred at "error" level - requested operation was not properly finished,
but no internal inconsistencies resulted
XXX_ERR  Internal error, things left inconsistent - continuing could crash system
The less serious errors have lower numerical value, so it is okay to use expressions like >= WARNING_ERR. In fact, it is better to use inequalities than equalities, since later some error levels may be inserted between those of the current list. NOTHING_ERR will always be the lowest, and XXX_ERR will always be the highest.

If the severity is XXX_ERR, then the event causing it is the fault of Netica, and you should contact Norsys about it (support@norsys.com), but if it is any of the others, you should be able to change your software to remove any problems.

Version:

This function is available in all versions.
In the C Version of the API, this function is called ErrorSeverity_ns.
See Also:
getIdNumber  Return the error's identification number
isInCategory  Return what kind of error it is


getMessage

public java.lang.String getMessage()
Given a report of an error, this returns a message explaining the error.

The message will start with the name of the Netica API function which was executing when the error occurred (the one you called, not any that are called internally), followed by a colon, and then a descriptive part. Generally the descriptive part is not just a generic message corresponding to the error number, but rather names the elements involved, and describes what went wrong.

Version:

This function is available in all versions.
In the C Version of the API, this function is called ErrorMessage_ns.
See Also:
getIdNumber  Returns the error's identification number
getSeverity  Returns how serious the error is
isInCategory  Returns what kind of error it is


isInCategory

public boolean isInCategory(int errcnd)
Returns a boolean to indicate whether this error was caused by the condition errcnd.

This is to discover the reason behind an error which has occurred. It groups together errors into broad classes.

For errcnd pass one of the conditions below, and the return value will be true iff that was a cause of the error. Note that some errors could have more than one cause.

Possible values for errcnd are:
OUT_OF_MEMORY_CND  System did not have enough memory to complete operation
INCONS_FINDING_CND  Inconsistent finding (only)
USER_ABORTED_CND  User halted the function before it completed (not possible when using a Netica API version without the user interface)
FROM_DEVELOPER_CND  Your program indicated the error by constructing a NeticaException
FROM_WRAPPER_CND  Error occurred in a language specific converter for VB, JAVA, or C++, etc.


Version:

Versions 1.30 and later have this function.
In the C Version of the API, this function is called ErrorCategory_ns.
See Also:
getIdNumber  Return the error's identification number
getMessage  Return a complete error message
getSeverity  Return how serious the error is

Parameters:
errcnd - The ERROR_CATEGORY to be tested.

getWarnings

public static java.util.Vector getWarnings(int severity)
                                    throws NeticaException
Retrieve and clear (remove) all messages from the current default Environment that are below the severity level for generating a NeticaException. For severity submit one of: NOTHING_ERR, REPORT_ERR, NOTICE_ERR, and WARNING_ERR. All the warnings that are at this severity level or higher will be retured.

If there are no warnings at the given severity level or higher, null is returned.

The warnings that are returned are also removed from Netica. This means that subsequent calls to getWarnings will not return them.

Version:

This function is available in all versions.
In the C Version of the API, this function is called ErrorWarnings_ns.
Example #1:
  Vector warnings = NeticaError.getWarnings( NeticaError.NOTICE_ERR); //clears all warnings
  node1.addLink( node2 );
  node2.addLink( node1 );
  warnings = NeticaError.getWarnings( NeticaError.WARNING_ERR);
  if ( warnings != null ){
      System.err.println("Oops, created a cycle.");
  }
Example #2:
  Vector warnings = NeticaError.getWarnings( NeticaError.NOTICE_ERR); //clears all warnings
  net = new Net( file ); // a file read can generate warnings
  Vector warnings = NeticaError.getWarnings( NeticaError.WARNING_ERR );
  if (warnings != null){
      for( int w=0; w < warnings.size(); w++ ) {
          NeticaError ne = (NeticaError) warnings.get(w);
          System.err.println("*** WARNING ***  : " + ne);
      }
  }
Parameters:
severity - The level of errors and higher to retrieve; one of NOTHING_ERR, REPORT_ERR, NOTICE_ERR, or WARNING_ERR.

toString

public java.lang.String toString()
Returns a readable string representation of this error.

Version:
This function is available in all versions.
Example:
 try {
   net.setName( "This name is illegal" );
 }
 catch (NeticaException ne) {
   ne.printStackTrace();
 }
 // would generate the following output.  Note, a NeticaException's printStackTrace method
 // will call the toString() method of each NeticaError within it.
 **************  E R R O R  ***************
 ** ErrorNumber   = 5118
 ** ErrorSeverity = ERROR_ERR
 ** ErrorCategory =
 ** ErrorMessage  = SetNetName_bn: Name string passed is bad because 'This name is illegal' contains a space
 ******************************************
Overrides:
toString in class java.lang.Object