C12Adapter Opensource C++ Interface
MException Class Reference

Common exception base for MeteringSDK. More...

Inheritance diagram for MException:

Public Types

enum  KindType {
  ErrorNone = 0,
  ErrorInformation = 1,
  ErrorWarning = 2,
  Error = 3,
  ErrorFatal = 4,
  ErrorCommunication = 5,
  ErrorSystem = 6,
  ErrorSocket = 7,
  ErrorConfiguration = 8,
  ErrorSecurity = 9,
  ErrorMeter = 10,
  ErrorSoftware = 15,
  ErrorUser = 20
}
 Enumeration that stands for the kind of the exception. More...
 
enum  { MaximumVisibleParameterLength = 64 }
 

Public Member Functions

 MException ()
 Object constructor. More...
 
 MException (const MStdString &message, MErrorEnum::Type code=MErrorEnum::ClientApplicationError, KindType kind=MException::ErrorUser)
 Object constructor with code, kind and variable number of parameters. More...
 
 MException (const MException &ex)
 Object copy constructor. More...
 
virtual ~MException ()
 Object destructor.
 
void InitAll (MException::KindType kind, MErrorEnum::Type code, const MStdString &message)
 Initialize all exception fields with the exact given data.
 
MExceptionoperator= (const MException &ex)
 Assignment operator. More...
 
virtual MStdString AsSimplifiedString () const
 Return a possibly simplified string that specifies information about exception. More...
 
virtual MStdString AsString () const
 Return the string that specifies extended information about exception. More...
 
MStdString GetMessageString () const
 Returns the message that is stored in this exception object. More...
 
void SetMessageString (const MStdString &msg)
 Sets the new message to exception. More...
 
MStdString GetKindAsString () const
 Return a string that represents the exception error kind. More...
 
MStdString GetFileName () const
 Get the file name where the error took place, if this information is available.
 
unsigned GetFileLineNumber () const
 Get the line number within file where the error took place.
 
void UpdateFileNameAndLineNumber (MFileNameAndLineNumber fl)
 Set file name and line number where the compile error took place, if the exception does not have this information already.
 
void UpdateFileAndLine (const MStdString &file, unsigned line)
 If not set already, set file name and line number associated with this exception. More...
 
void AddFileAndLineToStack (const MStdString &file, unsigned line)
 Add file name and line number context associated with this exception into stack. More...
 
void AddFileNameAndLineNumberToStack (MFileNameAndLineNumber fl)
 Add file name and line number context associated with this exception into stack. More...
 
const MFileNameAndLineNumber::VectorTypeGetStack () const
 Get the stack of file names and line numbers.
 
MStdStringVector GetCallStack () const
 Get the stack of file names and line numbers as collection of strings.
 
void Append (const MStdString &)
 Append the specified string to the end of the exception string. More...
 
void Prepend (const MStdString &)
 Prepend the specified string before the beginning of the exception string. More...
 
virtual MExceptionNewClone () const
 M_NO_VERBOSE_ERROR_INFORMATION. More...
 
virtual M_NORETURN_FUNC void Rethrow ()
 Rethrows this exception. More...
 
MErrorEnum::Type GetCode () const
 
void SetCode (MErrorEnum::Type code)
 
KindType GetKind () const
 
void SetKind (KindType kind)
 
void Init (KindType kind, MErrorEnum::Type code, MConstLocalChars str,...)
 Initialize the exception with the given message code and kind from which the message string is fetched from the resource. More...
 
void Init (KindType kind, MErrorEnum::Type code, const char *str,...)
 Initialize the exception with the given message code and kind from which the message string is fetched from the resource. More...
 
void Init (MErrorEnum::Type code, MConstLocalChars str,...)
 Initialize the exception with the given message code and kind from which the message string is fetched from the resource. More...
 
void Init (MErrorEnum::Type code, const char *str,...)
 Initialize the exception with the given message code and kind from which the message string is fetched from the resource. More...
 
void InitVA (KindType kind, MErrorEnum::Type code, MConstLocalChars str, va_list va)
 Initialize the exception with the given message code from the VA list argument. More...
 
void InitVA (KindType kind, MErrorEnum::Type code, const char *str, va_list va)
 Initialize the exception with the given message code from the VA list argument. More...
 
void InitVA (MErrorEnum::Type code, MConstLocalChars str, va_list va)
 Initialize the exception with the given message code from the VA list argument. More...
 
void InitVA (MErrorEnum::Type code, const char *str, va_list va)
 Initialize the exception with the given message code from the VA list argument. More...
 
MFileNameAndLineNumber GetFileNameAndLineNumber () const
 
void SetFileNameAndLineNumber (MFileNameAndLineNumber fl)
 
void AppendToString (MConstLocalChars str,...)
 
void AppendToString (const char *str,...)
 
void PrependBeforeString (MConstLocalChars str,...)
 
void PrependBeforeString (const char *str,...)
 
- Public Member Functions inherited from MObject
virtual ~MObject ()
 Object destructor.
 
virtual const MClassGetClass () const =0
 Get the final class of the object. More...
 
virtual unsigned GetEmbeddedSizeof () const
 For embedded object types, return the size of the class. More...
 
bool IsEmbeddedObject () const
 Tell if the object is of embedded kind. More...
 
SHOW_INTERNAL MVariant Call (const MStdString &name, const MVariant &params)
 Call the object service with parameters, given as variant. More...
 
MVariant Call0 (const MStdString &name)
 Call the object service with no parameters. More...
 
MVariant Call1 (const MStdString &name, const MVariant &p1)
 Call the object service with one parameter. More...
 
MVariant Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2)
 Call the object service with two parameter. More...
 
MVariant Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3)
 Call the object service with three parameter. More...
 
MVariant Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4)
 Call the object service with four parameter. More...
 
MVariant Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5)
 Call the object service with five parameter. More...
 
MVariant Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6)
 Call the object service with six parameter. More...
 
virtual MVariant CallV (const MStdString &name, const MVariant::VariantVector &params)
 Call the object service with parameters, given as variant vector. More...
 
virtual bool IsPropertyPresent (const MStdString &name) const
 Tell if the property with the given name exists.
 
virtual bool IsServicePresent (const MStdString &name) const
 Tell if the service with the given name exists.
 
virtual MVariant GetProperty (const MStdString &name) const
 Get the property value using name of the property. More...
 
virtual void SetProperty (const MStdString &name, const MVariant &value)
 Set the property using name of the property, and value. More...
 
virtual MStdStringVector GetAllPropertyNames () const
 Return the list of publicly available properties, persistent or not. More...
 
virtual MStdStringVector GetAllPersistentPropertyNames () const
 Return the list of persistent properties. More...
 
virtual void SetPersistentPropertiesToDefault ()
 Set the persistent properties of the object to their default values. More...
 
virtual MVariant GetPersistentPropertyDefaultValue (const MStdString &name) const
 Get the default value of persistent property with the name given. More...
 
virtual void SetPersistentPropertyToDefault (const MStdString &name)
 Set the persistent property with the name given to default value. More...
 
virtual const char * GetType () const
 Get the name of the type for the object (could be the same as class name).
 
virtual void SetType (const MStdString &)
 Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More...
 
virtual void Validate ()
 Validate internal structures of the object. More...
 

Static Public Member Functions

static MExceptionNew ()
 Create a new exception of this type, all parameters are clear.
 
static M_NORETURN_FUNC void ThrowUnknownError ()
 Throws this exception as unknown error. More...
 
static M_NORETURN_FUNC void ThrowCannotIndexItem (MConstChars itemName=NULL)
 Throws this exception as error that signifies the item cannot be indexed.
 
static M_NORETURN_FUNC void ThrowNotSupportedForThisType ()
 Throws this exception as error that signifies the operation is not supported for such type.
 
static M_NORETURN_FUNC void ThrowNoValue ()
 Throws this exception as error that signifies the value is absent.
 
static M_NORETURN_FUNC void ThrowNoValue (MFileNameAndLineNumber fl)
 Throws this exception as error that signifies the value given in file and line is absent.
 
static M_NORETURN_FUNC void ThrowBadTimeValue (MConstChars str=NULL)
 Throws this exception as error that signifies the time value is bad.
 
static M_NORETURN_FUNC void ThrowDivisionByZero ()
 Throws this exception as division by zero.
 
static M_NORETURN_FUNC void ThrowCallOutOfSequence ()
 Throws an error that the call is made out of sequence.
 
static M_NORETURN_FUNC void ThrowBadFileFormat (const MStdString &fileName)
 Throws file has bad format.
 
static M_NORETURN_FUNC void ThrowUnexpectedChar (int ch)
 Throws an exception that complains about an unexpected character. More...
 
static M_NORETURN_FUNC void ThrowStringTooLong (int stringLength, int maximumPossibleLength)
 Throws an exception that tells that the string is bigger than the maximum length. More...
 
static M_NORETURN_FUNC void ThrowUnsupportedType (int typetag)
 Throws an error that the given variant type is not supported.
 
static M_NORETURN_FUNC void Throw (const MStdString &message, MErrorEnum::Type code=MErrorEnum::ClientApplicationError)
 Throw this exception with the user message given as parameter. More...
 
static MStdString SimplifyMessageString (const MStdString &message)
 Attempt to simplify the error message string given. More...
 
static MStdString GetKindAsStringStatic (KindType kind)
 Return a string that represents the exception error kind using kind as parameter. More...
 
static MStdString VisualizeParameter (const MVariant &v)
 Make the given variant suitable for showing in error message. More...
 
static char * VisualizeVariantParameter (char *buff, const MVariant &v)
 Make the given variant parameter suitable for showing in error message. More...
 
static char * VisualizeStringParameter (char *buff, const MStdString &v)
 Make the given string parameter suitable for showing in error message. More...
 
static char * VisualizeCharsParameter (char *buff, const char *v)
 Make the given zero terminated string parameter suitable for showing in error message. More...
 
static char * VisualizeCharsParameter (char *buff, const char *v, unsigned len)
 Make the given not zero terminated character parameter suitable for showing in error message. More...
 
static M_NORETURN_FUNC void ThrowSyntaxError (MConstChars offendingString)
 
static M_NORETURN_FUNC void ThrowSyntaxError (MConstChars offendingString, size_t offendingStringLength)
 
static M_NORETURN_FUNC void ThrowUnknownItem (MException::KindType kind, MConstChars name)
 
static M_NORETURN_FUNC void ThrowUnknownItem (MConstChars name)
 
static M_NORETURN_FUNC void ThrowUnknownItem (MException::KindType kind, const MStdString &name)
 
static M_NORETURN_FUNC void ThrowUnknownItem (const MStdString &name)
 
static M_NORETURN_FUNC void Throw (MErrorEnum::Type code, MConstLocalChars str,...)
 
static M_NORETURN_FUNC void Throw (MErrorEnum::Type code, const char *str,...)
 
static M_NORETURN_FUNC void Throw (KindType kind, MErrorEnum::Type code, MConstLocalChars str,...)
 
static M_NORETURN_FUNC void Throw (KindType kind, MErrorEnum::Type code, const char *str,...)
 
- Static Public Member Functions inherited from MObject
static const MClassGetStaticClass ()
 Get the declared class of this particular object. More...
 
static bool IsClassPresent (const MStdString &name)
 Tells if the given class name is available. More...
 

Static Public Attributes

static const char s_itemIsUnknownErrorString []
 Constant string "Item '%s' is unknown", shared through many libraries.
 
- Static Public Attributes inherited from MObject
static const MClass s_class
 Class of MObject.
 

Protected Attributes

MErrorEnum::Type m_code
 Message code for this exception.
 
KindType m_kind
 The kind type for this exception.
 
MStdString m_message
 Message string that represents this exception.
 
MFileNameAndLineNumber m_fileNameAndLineNumber
 File name and line number where the compile error took place. More...
 
MFileNameAndLineNumber::VectorType m_stack
 Stack of file names and line numbers.
 

Additional Inherited Members

- Protected Member Functions inherited from MObject
 MObject ()
 Object constructor, protected as the class is abstract.
 
void DoSetPersistentPropertiesToDefault (const MClass *staticClass)
 Set the persistent properties to their default values for one object provided the class for that object. More...
 

Detailed Description

Common exception base for MeteringSDK.

Exceptions are used in MeteringSDK for program-level error handling. If the error log has to be made, it has to be made separately - no exceptions are logged.

Exceptions have an associated message code, which is helpful to implement the interfaces that do not support exceptions (like DCOM). Also there is a severity associated. The majority of the exceptions have the ERROR severity. The severity information is not stored with the exception, but fetched from the resource. There is a string associated with each exception, that is fetched from the locale sensitive resource.

There is a most general message code ErrUnknown.

File and line information can be associated with the whole exception. In case the error relates to the whole file, like M_FILE_S1_NOT_OPEN, the line number could be zero.

User applications can throw MException with direct strings. The user exception would normally define a constructor with parameters, which should actually be used during throwing, and also its default constructor, copy constructor, assignment operator and destructor. In most cases there is no need to overload any other services.

Member Enumeration Documentation

anonymous enum
Enumerator
MaximumVisibleParameterLength 

maximum desired parameter length when it is represented as string

Enumeration that stands for the kind of the exception.

This enumeration is reflected.

The client applications can define their own values.

Enumerator
ErrorNone 

The message is just a string, no severity.

ErrorInformation 

Information, not an error, for example, "Operation cancelled".

ErrorWarning 

The message is a warning.

Error 

Generalized error.

ErrorFatal 

Fatal error, one after which the application will not be functional, most likely.

ErrorCommunication 

Communication error.

ErrorSystem 

System error.

ErrorSocket 

Socket error.

ErrorConfiguration 

Configuration error, such as missing registry entry.

ErrorSecurity 

The error is due to security problem.

ErrorMeter 

The error is in the meter.

ErrorSoftware 

Exception is not suitable for showing to end users.

ErrorUser 

Application error start from this code.

Constructor & Destructor Documentation

MException::MException ( )

Object constructor.

Builds an empty exception.

MException::MException ( const MStdString message,
MErrorEnum::Type  code = MErrorEnum::ClientApplicationError,
KindType  kind = MException::ErrorUser 
)
explicit

Object constructor with code, kind and variable number of parameters.

Builds an exception with the given message code and kind. The string is fetched from the resource and it has format of printf operator, which allows multiple parameters to follow it.

Precondition
The number of parameters and their types given after the message code should correspond to the format of the message string. Otherwise the behavior is undefined.
MException::MException ( const MException ex)

Object copy constructor.

Precondition
The object given as parameter is a valid reference. Otherwise the behavior is undefined.

Member Function Documentation

void MException::AddFileAndLineToStack ( const MStdString file,
unsigned  line 
)

Add file name and line number context associated with this exception into stack.

The method is a convenient shortcut that can be put in every exception catcher that has context of a file and line.

See also
UpdateFileAndLine - This call not only updates the stack, but also sets file and line information of the exception if it was not set previously.
void MException::AddFileNameAndLineNumberToStack ( MFileNameAndLineNumber  fl)

Add file name and line number context associated with this exception into stack.

The method is a convenient shortcut that can be put in every exception catcher that has context of a file and line.

See also
UpdateFileAndLine - This call not only updates the stack, but also sets file and line information of the exception if it was not set previously.
AddFileAndLineToStack - version that takes file as string and line as number.
void MException::Append ( const MStdString )

Append the specified string to the end of the exception string.

This service is typically used for the tracing the exception code. For that someone has to catch MException, issue Append, and throw it again to the upper level. Also look at AppendToString for appending message codes.

void MException::AppendToString ( MConstLocalChars  str,
  ... 
)

Append the message specified by the code given to the current error string of the exception. This service is typically used for the tracing the exception code. For that someone has to catch MException, issue AppendToString, and throw it again to the upper level. Also look at Append for appending whole strings.

void MException::AppendToString ( const char *  str,
  ... 
)

Append the message specified by the code given to the current error string of the exception. This service is typically used for the tracing the exception code. For that someone has to catch MException, issue AppendToString, and throw it again to the upper level. Also look at Append for appending whole strings.

virtual MStdString MException::AsSimplifiedString ( ) const
virtual

Return a possibly simplified string that specifies information about exception.

This is an overloaded service that makes use of knowledge of exceptions of the upper level components. For this particular implementation SimplifyMessageString() is called. In many cases, AsString and AsSimplifiedString will return the same string.

See also
AsString
virtual MStdString MException::AsString ( ) const
virtual

Return the string that specifies extended information about exception.

There is also AsSimplifiedString, which might, or might not do something to simplify string information, so it is useful for an end user.

See also
AsSimplifiedString
MErrorEnum::Type MException::GetCode ( ) const
inline

Error code of the exception.

This service is useful to support C interfaces, logging, etc.

MFileNameAndLineNumber MException::GetFileNameAndLineNumber ( ) const
inline

Get file name and line number where the compile error took place.

KindType MException::GetKind ( ) const
inline

Message kind of the exception.

The client applications can define their own values bigger than value of ErrorUser.

MStdString MException::GetKindAsString ( ) const

Return a string that represents the exception error kind.

This call is useful for example for showing a dialog box with an error message, in which case, this would be a heading of the dialog.

static MStdString MException::GetKindAsStringStatic ( KindType  kind)
static

Return a string that represents the exception error kind using kind as parameter.

This is a static version of GetKindAsString.

MStdString MException::GetMessageString ( ) const
inline

Returns the message that is stored in this exception object.

Used in serialization.

void MException::Init ( KindType  kind,
MErrorEnum::Type  code,
MConstLocalChars  str,
  ... 
)

Initialize the exception with the given message code and kind from which the message string is fetched from the resource.

Precondition
The number of parameters and their types given after message string should correspond to the format of the message string in the resource. Otherwise the behavior is undefined.
void MException::Init ( KindType  kind,
MErrorEnum::Type  code,
const char *  str,
  ... 
)

Initialize the exception with the given message code and kind from which the message string is fetched from the resource.

Precondition
The number of parameters and their types given after message string should correspond to the format of the message string in the resource. Otherwise the behavior is undefined.
void MException::Init ( MErrorEnum::Type  code,
MConstLocalChars  str,
  ... 
)

Initialize the exception with the given message code and kind from which the message string is fetched from the resource.

Precondition
The number of parameters and their types given after message string should correspond to the format of the message string in the resource. Otherwise the behavior is undefined.
void MException::Init ( MErrorEnum::Type  code,
const char *  str,
  ... 
)

Initialize the exception with the given message code and kind from which the message string is fetched from the resource.

Precondition
The number of parameters and their types given after message string should correspond to the format of the message string in the resource. Otherwise the behavior is undefined.
void MException::InitVA ( KindType  kind,
MErrorEnum::Type  code,
MConstLocalChars  str,
va_list  va 
)

Initialize the exception with the given message code from the VA list argument.

Precondition
The number of parameters and their types given should correspond to the format of the message string within the resource. Otherwise the behavior is undefined.
void MException::InitVA ( KindType  kind,
MErrorEnum::Type  code,
const char *  str,
va_list  va 
)

Initialize the exception with the given message code from the VA list argument.

Precondition
The number of parameters and their types given should correspond to the format of the message string within the resource. Otherwise the behavior is undefined.
void MException::InitVA ( MErrorEnum::Type  code,
MConstLocalChars  str,
va_list  va 
)

Initialize the exception with the given message code from the VA list argument.

Precondition
The number of parameters and their types given should correspond to the format of the message string within the resource. Otherwise the behavior is undefined.
void MException::InitVA ( MErrorEnum::Type  code,
const char *  str,
va_list  va 
)

Initialize the exception with the given message code from the VA list argument.

Precondition
The number of parameters and their types given should correspond to the format of the message string within the resource. Otherwise the behavior is undefined.
virtual MException* MException::NewClone ( ) const
virtual

M_NO_VERBOSE_ERROR_INFORMATION.

Clone the exception, so the new exception has the same final type.

Returns
New exception, which is the same as this.
See also
Rethrow() Rethrows the cloned exception with respect to the final exception type.

Reimplemented in MEMath, MEIndexOutOfRange, MENumberOutOfRange, MEOperationCancelled, MECollisionDetected, MESocketError, MEChannelDisconnectedUnexpectedly, MESystemError, MEChannelWriteTimeout, MEChannelReadTimeout, MEC12BadProcedureResult, MEC12NokResponse, and MCOMException.

MException& MException::operator= ( const MException ex)

Assignment operator.

Be careful while using the assignment operator when dealing with children of this class, as the properties of a child might not be copied correctly.

Parameters
exException from which to copy this exception.
Returns
Reference to this object.
void MException::Prepend ( const MStdString )

Prepend the specified string before the beginning of the exception string.

This service is typically used for the tracing the exception code. For that someone has to catch MException, issue Prepend, and throw it again to the upper level. Also look at PrependBeforeString for appending message codes.

void MException::PrependBeforeString ( MConstLocalChars  str,
  ... 
)

Prepend the message specified by the code given before the current error string of the exception. This service is typically used for the tracing the exception code. For that someone has to catch MException, issue PrependBeforeString, and throw it again to the upper level.

void MException::PrependBeforeString ( const char *  str,
  ... 
)

Prepend the message specified by the code given before the current error string of the exception. This service is typically used for the tracing the exception code. For that someone has to catch MException, issue PrependBeforeString, and throw it again to the upper level.

virtual M_NORETURN_FUNC void MException::Rethrow ( )
virtual

Rethrows this exception.

This polymorphic call is necessary if a generic exception is caught by its base, and had to be saved for future throwing. Simple "throw *ex" will not work in this case, as it will call the copy constructor of the declared exception, not the final class copy constructor.

See also
NewClone() Clones the exception so the new exception has the same final type.

Reimplemented in MEMath, MEIndexOutOfRange, MENumberOutOfRange, MEOperationCancelled, MECollisionDetected, MESocketError, MEChannelDisconnectedUnexpectedly, MESystemError, MEChannelWriteTimeout, MEChannelReadTimeout, MEC12BadProcedureResult, MEC12NokResponse, and MCOMException.

void MException::SetCode ( MErrorEnum::Type  code)
inline

Error code of the exception.

This service is useful to support C interfaces, logging, etc.

void MException::SetFileNameAndLineNumber ( MFileNameAndLineNumber  fl)
inline

Get file name and line number where the compile error took place.

void MException::SetKind ( KindType  kind)
inline

Message kind of the exception.

The client applications can define their own values bigger than value of ErrorUser.

void MException::SetMessageString ( const MStdString msg)
inline

Sets the new message to exception.

Used in serialization.

static MStdString MException::SimplifyMessageString ( const MStdString message)
static

Attempt to simplify the error message string given.

This is an overloaded service that makes use of knowledge of exceptions of the upper level components. Extra information suitable to experts is removed to make the message more readable to casual users.

Parameters
messageError message text to simplify.
Returns
A simplified message, or the same message as given if no simplification is possible.
See also
AsSimplifiedString()
static M_NORETURN_FUNC void MException::Throw ( MErrorEnum::Type  code,
MConstLocalChars  str,
  ... 
)
static

Throws this exception with the parameters given. Analog of the following code:

throw MException(code, par1, par2, parN);

but saves memory, if there are many throws in the source code. The following is the usage:

MException::Throw(code, par1, par2, parN);
static M_NORETURN_FUNC void MException::Throw ( MErrorEnum::Type  code,
const char *  str,
  ... 
)
static

Throws this exception with the parameters given. Analog of the following code:

throw MException(code, par1, par2, parN);

but saves memory, if there are many throws in the source code. The following is the usage:

MException::Throw(code, par1, par2, parN);
static M_NORETURN_FUNC void MException::Throw ( KindType  kind,
MErrorEnum::Type  code,
MConstLocalChars  str,
  ... 
)
static

Throws this exception with the parameters given. Analog of the following code:

throw MException(kind, code, par1, par2, parN);

but saves memory, if there are many throws in the source code. The following is the usage:

MException::Throw(kind, code, par1, par2, parN);
static M_NORETURN_FUNC void MException::Throw ( KindType  kind,
MErrorEnum::Type  code,
const char *  str,
  ... 
)
static

Throws this exception with the parameters given. Analog of the following code:

throw MException(kind, code, par1, par2, parN);

but saves memory, if there are many throws in the source code. The following is the usage:

MException::Throw(kind, code, par1, par2, parN);
static M_NORETURN_FUNC void MException::Throw ( const MStdString message,
MErrorEnum::Type  code = MErrorEnum::ClientApplicationError 
)
static

Throw this exception with the user message given as parameter.

Analog of the following code:

throw MException(message, code);

but saves memory, if there are many throws in the source code. The following is the usage:

MException::Throw("Error in my application");
static M_NORETURN_FUNC void MException::ThrowStringTooLong ( int  stringLength,
int  maximumPossibleLength 
)
static

Throws an exception that tells that the string is bigger than the maximum length.

Parameters
stringLengthString length that was encountered, too big.
maximumPossibleLengthExpected maximum possible length.
static M_NORETURN_FUNC void MException::ThrowSyntaxError ( MConstChars  offendingString)
static

Throws this exception as syntax error exception.

static M_NORETURN_FUNC void MException::ThrowSyntaxError ( MConstChars  offendingString,
size_t  offendingStringLength 
)
static

Throws this exception as syntax error exception.

static M_NORETURN_FUNC void MException::ThrowUnexpectedChar ( int  ch)
static

Throws an exception that complains about an unexpected character.

Parameters
chCharacter that is to be reported as unexpected.
static M_NORETURN_FUNC void MException::ThrowUnknownError ( )
static

Throws this exception as unknown error.

Analog of the following code:

throw MException();

but saves memory, if there are many throws in the source code. The following is the usage:

static M_NORETURN_FUNC void MException::ThrowUnknownItem ( MException::KindType  kind,
MConstChars  name 
)
static

Throws unknown item exception with the name given as constant pointer to character string.

static M_NORETURN_FUNC void MException::ThrowUnknownItem ( MConstChars  name)
static

Throws unknown item exception with the name given as constant pointer to character string.

static M_NORETURN_FUNC void MException::ThrowUnknownItem ( MException::KindType  kind,
const MStdString name 
)
static

Throws unknown item exception with the name given as constant pointer to character string.

static M_NORETURN_FUNC void MException::ThrowUnknownItem ( const MStdString name)
static

Throws unknown item exception with the name given as constant pointer to character string.

void MException::UpdateFileAndLine ( const MStdString file,
unsigned  line 
)

If not set already, set file name and line number associated with this exception.

The method is a convenient shortcut that can be put in every exception catcher that has context of a file and line. Also, this call updates the stack associated with this exception.

See also
AddFileAndLineToStack - this call only adds file and line context to stack associated with exception.
static char* MException::VisualizeCharsParameter ( char *  buff,
const char *  v 
)
static

Make the given zero terminated string parameter suitable for showing in error message.

This is a static method, use it to convert individual parameters in the error message. The given string will be truncated, if longer than MException::MaximumVisibleParameterLength characters, and all non-printables in the given string will be C-escaped.

Parameters
buffBuffer of at least MException::MaximumVisibleParameterLength bytes long where the string will be constructed. If more than one parameter in the message has to be converted, they all shall have different buff.
vValue to visualize for showing in the error message.
Returns
The result zero terminated string buffer, truncated and escaped if necessary, built in the supplied buff parameter.
See also
VisualizeParameter the method that returns a string.
static char* MException::VisualizeCharsParameter ( char *  buff,
const char *  v,
unsigned  len 
)
static

Make the given not zero terminated character parameter suitable for showing in error message.

This is a static method, use it to convert individual parameters in the error message. The given string will be truncated, if longer than MException::MaximumVisibleParameterLength characters, and all non-printables in the given string will be C-escaped.

Parameters
buffBuffer of at least MException::MaximumVisibleParameterLength bytes long where the string will be constructed. If more than one parameter in the message has to be converted, they all shall have different buff.
vValue to visualize for showing in the error message, not zero terminated.
lenByte size of v.
Returns
The result zero terminated string buffer, truncated and escaped if necessary, built in the supplied buff parameter.
See also
VisualizeParameter the method that returns a string.
static MStdString MException::VisualizeParameter ( const MVariant v)
static

Make the given variant suitable for showing in error message.

This is a static method, use it to convert individual parameters. Representation of the given variant will not exceed MException::MaximumVisibleParameterLength characters, and all non-printables in the given string will be C-escaped.

Parameters
vValue to visualize for showing in the error message.
Returns
The result string, truncated and escaped if necessary.
static char* MException::VisualizeStringParameter ( char *  buff,
const MStdString v 
)
static

Make the given string parameter suitable for showing in error message.

This is a static method, use it to convert individual parameters in the error message. The given string will be truncated, if longer than 40 characters, and all non-printables in the given string will be C-escaped.

Parameters
buffBuffer of at least MException::MaximumVisibleParameterLength bytes long where the string will be constructed. If more than one parameter in the message has to be converted, they all shall have different buff.
vValue to visualize for showing in the error message.
Returns
The result zero terminated string buffer, truncated and escaped if necessary, built in the supplied buff parameter.
See also
VisualizeParameter the method that returns a string.
static char* MException::VisualizeVariantParameter ( char *  buff,
const MVariant v 
)
static

Make the given variant parameter suitable for showing in error message.

This is a static method, use it to convert individual parameters in the error message. The given variant will be converted into string, truncated if longer than 40 characters, and all non-printables will be C-escaped.

Parameters
buffBuffer of at least MException::MaximumVisibleParameterLength bytes long where the string will be constructed. If more than one parameter in the message has to be converted, they all shall have different buff.
vValue to visualize for showing in the error message.
Returns
The result zero terminated string buffer, truncated and escaped if necessary, built in the supplied buff parameter.
See also
VisualizeParameter the method that returns a string.

Member Data Documentation

MFileNameAndLineNumber MException::m_fileNameAndLineNumber
protected

File name and line number where the compile error took place.

This can be zero, meaning no information is available.