Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

xmog_exception Class Reference
[Error Handling]

The wrapper for exceptions that occur on the Java side. More...

#include <xmog_exception.h>

Inheritance diagram for xmog_exception:

Inheritance graph
[legend]
Collaboration diagram for xmog_exception:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void get_message (xmog_base *msg, xmog_localenv *env=NULL)
 Returns the exception instance's message object in the provided proxy instance.
virtual char * get_message_chars (xmog_localenv *env=NULL, xmog_base *enc=NULL)
 Returns the error message for this instance.
virtual unsigned short * get_message_u16 (xmog_localenv *env=NULL)
 Returns the error message for this instance.
 xmog_exception (jobject inst, xmog_flags flags)
 The constructor for a preexisting exception instance.
 xmog_exception ()
 The default constructor.

Static Public Member Functions

static void throw_java_exception (xmog_exception *pe=NULL, const char *msg=NULL, xmog_localenv *env=NULL)
 Throws a Java exception corresponding with the passed exception instance.

Detailed Description

The wrapper for exceptions that occur on the Java side.

This class is mixed into all generated proxy exception types and therefore has to extend xmog_java_ref virtually. By mixing this type into all generated exception proxy types and by having the generic exception type implement this interface, we can allow the developer to catch all exceptions that are part of the framework (typed and generic) via the xmog_exception type.

A catch-all handler could look like this:

      try
      {
          // do things that could throw exceptions (framework or proxy)
      }
      catch( xmog_exception & e )
      {
          // get the exception message using the default encoding
          char *   msg = e.get_message_chars();
   
          // print it to the console if there is something to print
          if( msg )
              cout << msg << endl;
   
          // release the message string
          xmog_util::setString( msg, NULL );
      }


Constructor & Destructor Documentation

xmog_exception::xmog_exception jobject  inst,
xmog_flags  flags
 

The constructor for a preexisting exception instance.

Parameters:
inst the exception.
flags the housekeeping flags.


Member Function Documentation

void xmog_exception::get_message xmog_base msg,
xmog_localenv env = NULL
 

Returns the exception instance's message object in the provided proxy instance.

This method is used internally by the .NET bindings.

Parameters:
msg the object into which the message instance is set.
env the local call environment. May be NULL.

virtual char* xmog_exception::get_message_chars xmog_localenv env = NULL,
xmog_base enc = NULL
[virtual]
 

Returns the error message for this instance.

The caller is responsible for cleaning up the returned string by calling xmog_util::free() or xmog_util::setString().

Parameters:
env the local call environment. May be NULL.
enc the optional encoding to be used. Use one of the encodings in the xmog_java_string class.
Returns:
the exception message, owned by the caller.

Reimplemented in xmog_exception_impl.

virtual unsigned short* xmog_exception::get_message_u16 xmog_localenv env = NULL  )  [virtual]
 

Returns the error message for this instance.

The caller is responsible for cleaning up the returned string by calling xmog_util::free() or xmog_util::setString().

Parameters:
env the local call environment. May be NULL.
Returns:
the exception message, owned by the caller.

Reimplemented in xmog_exception_impl.

static void xmog_exception::throw_java_exception xmog_exception pe = NULL,
const char *  msg = NULL,
xmog_localenv env = NULL
[static]
 

Throws a Java exception corresponding with the passed exception instance.

If the passed exception instance is NULL or if it is not a proxy instance for a Java exception, a Java RuntimeException will be thrown.

Parameters:
pe a pointer to an exception instance. May be NULL.
msg an exception message to be used if the passed in exception instance does not represent a Java exception instance. May be NULL.
env the local call environment. May be NULL.


The documentation for this class was generated from the following file:
Generated on Fri Jun 16 10:19:02 2006 for JMS Courier for C++ by  doxygen 1.4.1