class MASKING_DLL_DECLSPEC Error

Represents an error code functions can return and you can check.

Public Methods

[more] Error(Type t = NONE)
The constructor for making a new Error object.
[more]virtual const char* GetDescription()
Returns a string containing a short description of the error.
[more]virtual operator bool() const
Casts an error code to a bool value.
[more]virtual bool operator==(const Type &t)
Compares two error codes.
[more]virtual bool operator!=(const Type &t)
Compares two error codes.
[more]void Report()
Prints an error message to the screen by using allegro_message() and exits the program.

Public Members

[more]enum Type
The type of the error.

Protected Fields

[more]Type type
The actual error code of the Error object


Documentation

Represents an error code functions can return and you can check. It contains some most common error codes but you can easily derive your own error class with your own errors. This class is most often used for checking whether installing some module or MASkinG itself was successfull or for checking if loading data has failed or something.
oenum Type
The type of the error. An Error can be one of the following values:
	NONE            - there was no error
	ALLEGRO         - error installing Allegro
	KEYBOARD        - error installing the keyboard module
	MOUSE           - error installing the mouse module
	TIMER           - error installing the timer module
	GFX             - error setting the graphics mode
	SOUND           - error installing the sound module (not fatal, just a warnin so to speak)
	MEMORY          - ran out of memory
	VIDEOMEMORY     - ran out of video memory
	TRIPLEBUFFER    - error setting triplebuffering
	SKIN_INI        - can't find a config file (skin)
	SKIN_DAT        - can't find or load a datafile (skin)
	NO_FILE         - file doesn't exist
	LOAD_FILE       - can't load a file
	ALFONT          - error installing or using AllegroFont
	INDEX           - wrong index for accessing an array or vector
	UNKNOWN         - an undetermined error (any values above UNKNOWN can be used by derived error classes)

oType type
The actual error code of the Error object

o Error(Type t = NONE)
The constructor for making a new Error object. Pass one of the possible error codes as the parameter to create an error.

ovirtual const char* GetDescription()
Returns a string containing a short description of the error. This can be used to print to the screen to inform the user of an error. If you derive your own error class you need to implement this function like this:
      virtual const char *MyErrror::GetDescription() {
          if (type > UNKNOWN) {
               return my own error description string
          }
          else {
              return Error::GetDescription();
          }
      }

ovirtual operator bool() const
Casts an error code to a bool value. If the error code represents a fatal error that requires the program to shut down this returns true otherwise it returns false. This enables you to do something like this:
      Error e = FunctionThatTriesToDoSomething();
      if (e) {
          ShutdownProgram();
      }

ovirtual bool operator==(const Type &t)
Compares two error codes. Return true if the error codes are the same.

ovirtual bool operator!=(const Type &t)
Compares two error codes. Return true if the error codes are different.

ovoid Report()
Prints an error message to the screen by using allegro_message() and exits the program. Call this when you catch a fatal error.


This class has no child classes.

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++