xmlBlaster 2.2.0 client API

org.xmlBlaster.util
Class XmlBlasterException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.xmlBlaster.util.XmlBlasterException
All Implemented Interfaces:
java.io.Serializable

public class XmlBlasterException
extends java.lang.Exception
implements java.io.Serializable

The basic exception handling class for xmlBlaster.

This exception will be thrown in remote RMI calls as well.

The getMessage() method returns a configurable formatted string here is an example how to configure the format in your xmlBlaster.properties:

  XmlBlasterException.logFormat=XmlBlasterException errorCode=[{0}] node=[{1}] location=[{2}] message=[{4} : {8}]
  XmlBlasterException.logFormat.internal= XmlBlasterException errorCode=[{0}] node=[{1}] location=[{2}]\nmessage={4} : {8}\nversionInfo={5}\nstackTrace={7}
  XmlBlasterException.logFormat.resource= defaults to XmlBlasterException.logFormat
  XmlBlasterException.logFormat.communication= defaults to XmlBlasterException.logFormat
  XmlBlasterException.logFormat.user= defaults to XmlBlasterException.logFormat
  XmlBlasterException.logFormat.transaction= defaults to XmlBlasterException.logFormat
  XmlBlasterException.logFormat.legacy= defaults to XmlBlasterException.logFormat
 
where the replacements are:
  {0} = errorCodeStr
  {1} = node
  {2} = location
  {3} = isServerSide     // exception thrown from server or from client?
  {4} = message
  {5} = versionInfo
  {6} = timestamp
  {7} = stackTrace
  {8} = embeddedMessage
  {9} = errorCode.getDescription()
  // {10} = transactionInfo       IBM's JDK MakeFormat only supports 9 digits
  // {11} = lang                  IBM's JDK MakeFormat only supports 9 digits
 

You can register your own exception handler which intercepts all XmlBlasterException creations and for example do a shutdown on certain ErrorCodes

 java -Dorg.xmlBlaster.util.I_XmlBlasterExceptionHandler=MyHandler org.xmlBlaster.Main
 
this must be a class implementing I_XmlBlasterExceptionHandler, as a default Main.java registers itself and does an immediate shutdown on RESOURCE_DB_UNAVAILABLE

Since:
0.8+ with extended attributes
Author:
"Marcel Ruff"
See Also:
The admin.errorcodes requirement, org.xmlBlaster.test.classtest.XmlBlasterExceptionTest, Serialized Form

Constructor Summary
XmlBlasterException(Global glob, ErrorCode errorCodeEnum, java.lang.String location)
          The errorCodeEnum.getDescription() is used as error message.
XmlBlasterException(Global glob, ErrorCode errorCodeEnum, java.lang.String location, java.lang.String message)
           
XmlBlasterException(Global glob, ErrorCode errorCodeEnum, java.lang.String node, java.lang.String location, java.lang.String lang, java.lang.String message, java.lang.String versionInfo, Timestamp timestamp, java.lang.String stackTrace, java.lang.String embeddedMessage, java.lang.String transcationInfo, boolean isServerSide)
          For internal use: Deserializing and exception creation from CORBA XmlBlasterException
XmlBlasterException(Global glob, ErrorCode errorCodeEnum, java.lang.String location, java.lang.String message, java.lang.Throwable cause)
           
XmlBlasterException(java.lang.String location, java.lang.String message)
          Deprecated. Please use constructor which uses ErrorCode
 
Method Summary
 void changeErrorCode(ErrorCode errorCodeEnum)
           
static XmlBlasterException convert(Global glob, ErrorCode errorCodeEnum, java.lang.String location, java.lang.String message, java.lang.Throwable throwable)
           
static XmlBlasterException convert(Global glob, java.lang.String location, java.lang.String message, java.lang.Throwable throwable)
          If throwable is of type XmlBlasterException it is just casted (and location/message are ignored) else if throwable is one if IllegalArgumentException, NullpointerException or OutOfMemoryError it is converted to an XmlBlasterException with corresponding ErrorCode otherwise the ErrorCode is INTERNAL_UNKNOWN
 java.lang.String createStackTrace()
           
static java.lang.String createStackTrace(java.lang.Throwable e)
           
static java.lang.String createVersionInfo()
           
 java.lang.Throwable getEmbeddedException()
          The original exception, note that this is not serialized.
 java.lang.String getEmbeddedMessage()
           
 ErrorCode getErrorCode()
           
 java.lang.String getErrorCodeStr()
           
static I_XmlBlasterExceptionHandler getExceptionHandler()
           
 Global getGlobal()
           
 java.lang.String getLang()
           
 java.lang.String getLocation()
           
 java.lang.String getMessage()
          Configurable with property XmlBlasterException.logFormat, XmlBlasterException.logFormat.internal XmlBlasterException.logFormat.resource etc.
 java.lang.String getNode()
           
 ErrorCode getOriginalErrorCode()
           
 java.lang.String getRawMessage()
          Get the original message text, it is prefixed by the current subversion revision number.
 java.lang.String getStackTraceStr()
           
 Timestamp getTimestamp()
          Timestamp when exception was thrown
 java.lang.String getTransactionInfo()
           
 java.lang.String getVersionInfo()
          A comma separated list with key/values containing detailed information about the server environment
 boolean isCleanupSession()
           
 boolean isCommunication()
           
 boolean isErrorCode(ErrorCode code)
           
 boolean isInternal()
           
 boolean isResource()
           
 boolean isServerSide()
           
 void isServerSide(boolean serverSide)
           
 boolean isTransaction()
           
 boolean isUser()
           
static void main(java.lang.String[] args)
          java org.xmlBlaster.util.XmlBlasterException
static XmlBlasterException parseByteArr(Global glob, byte[] data)
           
static XmlBlasterException parseByteArr(Global glob, byte[] data, ErrorCode fallback)
          Serialize the complete exception.
static XmlBlasterException parseToString(Global glob, java.lang.String toString, ErrorCode fallback)
          Parsing what toString() produced
 void setCleanupSession(boolean cleanupSession)
           
static void setExceptionHandler(I_XmlBlasterExceptionHandler exceptionHandler)
           
 void setLocation(java.lang.String location)
          Overwrite the location
 void setLogFormatInternal(java.lang.String logFormatInternal)
          Overwrite the formatting of internal logs (the env property -XmlBlasterException.logFormat.internal)
 byte[] toByteArr()
          Serialize the complete exception
 java.lang.String toString()
          Caution: The syntax is used by parseToString() to parse the stringified exception again.
This is used by XmlRpc, see XmlRpcConnection.extractXmlBlasterException()
 java.lang.String toXml()
           
 java.lang.String toXml(java.lang.String extraOffset)
          Create a XML representation of the Exception.
static XmlBlasterException tranformCallbackException(XmlBlasterException e)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlBlasterException

public XmlBlasterException(Global glob,
                           ErrorCode errorCodeEnum,
                           java.lang.String location)
The errorCodeEnum.getDescription() is used as error message.


XmlBlasterException

public XmlBlasterException(Global glob,
                           ErrorCode errorCodeEnum,
                           java.lang.String location,
                           java.lang.String message)

XmlBlasterException

public XmlBlasterException(Global glob,
                           ErrorCode errorCodeEnum,
                           java.lang.String location,
                           java.lang.String message,
                           java.lang.Throwable cause)

XmlBlasterException

public XmlBlasterException(Global glob,
                           ErrorCode errorCodeEnum,
                           java.lang.String node,
                           java.lang.String location,
                           java.lang.String lang,
                           java.lang.String message,
                           java.lang.String versionInfo,
                           Timestamp timestamp,
                           java.lang.String stackTrace,
                           java.lang.String embeddedMessage,
                           java.lang.String transcationInfo,
                           boolean isServerSide)
For internal use: Deserializing and exception creation from CORBA XmlBlasterException


XmlBlasterException

public XmlBlasterException(java.lang.String location,
                           java.lang.String message)
Deprecated. Please use constructor which uses ErrorCode

Method Detail

getOriginalErrorCode

public final ErrorCode getOriginalErrorCode()
Returns:
can be null

changeErrorCode

public final void changeErrorCode(ErrorCode errorCodeEnum)

getGlobal

public final Global getGlobal()

getErrorCode

public final ErrorCode getErrorCode()
Returns:
The error code enumeration object, is never null

isErrorCode

public final boolean isErrorCode(ErrorCode code)

getErrorCodeStr

public final java.lang.String getErrorCodeStr()

getNode

public final java.lang.String getNode()

getLocation

public final java.lang.String getLocation()

setLocation

public final void setLocation(java.lang.String location)
Overwrite the location


getLang

public final java.lang.String getLang()

getMessage

public java.lang.String getMessage()
Configurable with property XmlBlasterException.logFormat, XmlBlasterException.logFormat.internal XmlBlasterException.logFormat.resource etc.

Overrides:
getMessage in class java.lang.Throwable
Returns:
e.g. errorCode + ": " + getMessage() + ": " + getEmbeddedMessage()

getRawMessage

public final java.lang.String getRawMessage()
Get the original message text, it is prefixed by the current subversion revision number. For example: "#12702M Can't find class MyPlugin"

Returns:
The original message text, never null

getVersionInfo

public final java.lang.String getVersionInfo()
A comma separated list with key/values containing detailed information about the server environment


getTimestamp

public final Timestamp getTimestamp()
Timestamp when exception was thrown

Returns:
Never null

getEmbeddedException

public final java.lang.Throwable getEmbeddedException()
The original exception, note that this is not serialized.

Returns:
The original exception or null

getStackTraceStr

public final java.lang.String getStackTraceStr()
Returns:
The stack trace or null, e.g.
  stackTrace= errorCode=internal.unknown message=Bla bla
    at org.xmlBlaster.util.XmlBlasterException.main(XmlBlasterException.java:488)
 
The first line is the result from toString() and the following lines are the stackTrace

getEmbeddedMessage

public final java.lang.String getEmbeddedMessage()
Returns:
The toString() of the embedded exception which is :getMessage()
or null if not applicable

getTransactionInfo

public final java.lang.String getTransactionInfo()
Returns:
Not defined yet

isServerSide

public final boolean isServerSide()
Returns:
true if the exception occured on server side, false if happened on client side

isServerSide

public final void isServerSide(boolean serverSide)
Parameters:
serverSide - true to mark the exception has occurred on server side, false if happened on client side

isInternal

public boolean isInternal()

isResource

public boolean isResource()

isCommunication

public boolean isCommunication()

isUser

public boolean isUser()

isTransaction

public boolean isTransaction()

createStackTrace

public java.lang.String createStackTrace()

createStackTrace

public static java.lang.String createStackTrace(java.lang.Throwable e)

createVersionInfo

public static java.lang.String createVersionInfo()

toString

public java.lang.String toString()
Caution: The syntax is used by parseToString() to parse the stringified exception again.
This is used by XmlRpc, see XmlRpcConnection.extractXmlBlasterException()

Overrides:
toString in class java.lang.Throwable

parseToString

public static XmlBlasterException parseToString(Global glob,
                                                java.lang.String toString,
                                                ErrorCode fallback)
Parsing what toString() produced

Parameters:
glob -
toString - The original exception
fallback - The error code to use if 'toString' is unparsable

toXml

public final java.lang.String toXml()
See Also:
toXml(String)

toXml

public java.lang.String toXml(java.lang.String extraOffset)
Create a XML representation of the Exception.
   <exception errorCode='resource.outOfMemory'>
      <class>JavaClass</class>
      <message><![cdata[  bla bla ]]></message>
   </exception>
 


toByteArr

public byte[] toByteArr()
Serialize the complete exception


parseByteArr

public static XmlBlasterException parseByteArr(Global glob,
                                               byte[] data)

parseByteArr

public static XmlBlasterException parseByteArr(Global glob,
                                               byte[] data,
                                               ErrorCode fallback)
Serialize the complete exception. Take care when changing!!! Is used e.g. in CallbackServerUnparsed.c and XmlScriptInterpreter.java


convert

public static XmlBlasterException convert(Global glob,
                                          java.lang.String location,
                                          java.lang.String message,
                                          java.lang.Throwable throwable)
If throwable is of type XmlBlasterException it is just casted (and location/message are ignored) else if throwable is one if IllegalArgumentException, NullpointerException or OutOfMemoryError it is converted to an XmlBlasterException with corresponding ErrorCode otherwise the ErrorCode is INTERNAL_UNKNOWN

Parameters:
location - null if not of interest
message - null if not of interest
throwable - Any exception type you can think of
Returns:
An exception of type XmlBlasterException

convert

public static XmlBlasterException convert(Global glob,
                                          ErrorCode errorCodeEnum,
                                          java.lang.String location,
                                          java.lang.String message,
                                          java.lang.Throwable throwable)
Parameters:
errorCodeEnum - is the fallback error code

setLogFormatInternal

public void setLogFormatInternal(java.lang.String logFormatInternal)
Overwrite the formatting of internal logs (the env property -XmlBlasterException.logFormat.internal)


tranformCallbackException

public static XmlBlasterException tranformCallbackException(XmlBlasterException e)

main

public static void main(java.lang.String[] args)
java org.xmlBlaster.util.XmlBlasterException


getExceptionHandler

public static I_XmlBlasterExceptionHandler getExceptionHandler()
Returns:
Returns the exceptionHandler.

setExceptionHandler

public static void setExceptionHandler(I_XmlBlasterExceptionHandler exceptionHandler)
Parameters:
exceptionHandler - The exceptionHandler to set.

isCleanupSession

public boolean isCleanupSession()

setCleanupSession

public void setCleanupSession(boolean cleanupSession)

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.