Merror Class Reference

List of all members.

Public Functions

public Merror new (int stackdepth=> 64, string errorfile=> undef, boolean ramusage=> 0)
 Creates a new Merror object.
public int error (boolean flag=0)
 If called with an value != undef the internal state will be considered as an error. If called without a parameter, it will return the internal state where a positive value indicates an error. If called with a value != undef a stacktrace will be created.
public int ec (int errorCode=0)
 Returns or sets a error code.
public string et (string errorDescription="")
 Returns or sets an error description.
public void mappedError (int errorcode)
 Sets the errorcode to the given one and sets the error description from the error mapping file.
public void stacktrace ()
 Prints out a captured stacktrace in case of error.
public void merror_copy (Merror to)
 You could treat this function as a copy operator for Merror objects It copies the complete internal state into a new object.

Private Functions

private void fillstack ()
 Captures the stacktrace with a max depth of $self->{STACKDEPTH}.
private void parseErrorFile ()
 If user wants to parse the complete error mapping file and save it into ram than this function is called.
private string mapErrorCode (int errorcode)
 Returns the error description of the given errorcode. If errorcode is undef than an undefined error will be returned.


Detailed Description

Implementing a OOP style error handling class with an ability of printing out a stacktrace Revision:
Rev
4
Last changed:
Date
2010-02-17 23:32:19 +0100 (Wed, 17 Feb 2010)
By:
Author
nexus

Member Function Documentation

public int Merror::ec ( int  errorCode = 0  ) 

Returns or sets a error code.

Parameters:
errorCode If a value != undef is given, than this value will be treated as an errorcode If this function is called without a parameter it will return the last set errorCode
Returns:
scalar An error code

public int Merror::error ( boolean  flag = 0  ) 

If called with an value != undef the internal state will be considered as an error. If called without a parameter, it will return the internal state where a positive value indicates an error. If called with a value != undef a stacktrace will be created.

Parameters:
flag The parameter is optional and should only be set in classes using Merror not in interfaces implementing something
Returns:
scalar If called without a parameter it will return a 1 indicating that an error happended or a 0 to indicate that everything is fine

public string Merror::et ( string  errorDescription = ""  ) 

Returns or sets an error description.

Parameters:
errorDescription If a value != undef is given this value will be treated as a string and this string will be the error description. It no value is given than the last set error description will be given back
Returns:
scalar Error description

private string Merror::mapErrorCode ( int  errorcode  ) 

Returns the error description of the given errorcode. If errorcode is undef than an undefined error will be returned.

Parameters:
errorcode The errorcode
Returns:
string

public void Merror::mappedError ( int  errorcode  ) 

Sets the errorcode to the given one and sets the error description from the error mapping file.

Parameters:
errorcode The errorcode

public void Merror::merror_copy ( Merror  to  ) 

You could treat this function as a copy operator for Merror objects It copies the complete internal state into a new object.

Parameters:
to The destination hash structure

public Merror Merror::new ( int  stackdepth,
64  ,
string  errorfile,
undef  ,
boolean  ramusage,
 
)

Creates a new Merror object.

Parameters:
stackdepth Describes how deep the stacktrace should trace back the calls. Default = 64
errorfile Path to the file that contains the errorcode to errordescription mapping. Default = undef
ramusage Describes if set to 1 that the complete errormapping will be held in ram. Default = 0
Returns:
Merror object


The documentation for this class was generated from the following file:

Generated on Mon Mar 8 17:18:20 2010 for Merror by  doxygen 1.5.8