ccError

09/23/99

Author: Daniel.Lindh@Home.se
ICQ: 7983755
HOMEPAGE: home.bip.net/CyberCow

Copyright © Cyber Cow 1995 - 1999.
All Rights Reserved.

OverView
Class Members
Base Class ccTraceFile

 

Overview

#include <ccError.h>

Hierarchy Chart


A ccError object handles error detection, error number lookup, error logging, displaying error messages for MFC, win32 and ccLib routines and classes.

 

Class Members

Data Items:

Private:

None

Construction

Public:

ccError

Default Constructor

Input/Output

Public:

error

Shows the error message.

Properties

Public:

enableErrorWnd

Handles if the error window should be displayed when error is called.

ccTraceFile::enableLogging

Turn on and of the file logging.

 

 

ccError::ccError

void ccError( BOOL abEnableLogging = FALSE, BOOL abAppend = TRUE , 

              const char *asFileName = "ccError.err" );

Return Value:

None

Arguments:

abEnableLogging

If true enableing the error file logging.

abAppend

If true, the error messages will be appended to the error file. If false, the error file will be truncated to 0.

asFileName

The name of the error file.

Remarks:

This member will create the ccErrorHandler object. It will also enable the error window ( enableErrorWnd() ).

Example:

ccErrorHandler oErrorHandler;

 

ccError::error

int error(

            E_ERROR_TYPE aiErrorMode   = -1,
            int          aiErrorNumber = NULL,
            int          aiPrefixText  = NULL,
            int          aiSuffixText   = NULL,
            int          aiType        = MB_OK
         );

int error(

            CString  asErrorMessage = ""
            CString  asPrefixText   = "",
            CString  asSuffixText   = "",
            int      aiType         = MB_OK
         );


enum E_ERROR_MODE
{
   CCEM_GET_LAST_ERROR = 0,
   CCEM_ERROR_NUMBER,
   CCEM_ERROR_MESSAGE

};

Return Value:

int

Zero if there is not enough memory to display the message box; otherwise one of the following values is returned:

  • IDABORT   The Abort button was selected.
  • IDCANCEL   The Cancel button was selected.
  • IDIGNORE   The Ignore button was selected.
  • IDNO   The No button was selected.
  • IDOK   The OK button was selected.
  • IDRETRY   The Retry button was selected.
  • IDYES   The Yes button was selected.

If a message box has a Cancel button, the IDCANCEL value will be returned if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing the ESC key has no effect.

Arguments:

aiErrorMode

Tells how the error function should work. Using the E_ERROR_MODE enum. 

 

CCEM_GET_LAST_ERROR 

Will take the error number from the WIN32 function GetLastError. aiErrorNumber will be  unused. 

CCEM_ERROR_NUMBER,

Will take the error number from the aiErrorNumber, and compare it to the internal error table.

CCEM_ERROR_MESSAGE

Will take the error message from the string table using resource number from aiErrorNumber.

aiErrorNumber

See aiErrorMode

aiErrorPrefixText

This text will be shown before the error message. The text will be taken from the string table.

aiErrorSuffixText

This text will be shown after the error message. The text will be taken from the string table.

aiType

The style of the message box. <see MessageBox for more information>

asErrorMessage

This is the error message the routine will display and log.

asPrefixText

This text will be shown before the error message.

asSuffixText

This text will be shown after the error message.

Remarks:

This function will dispaly an error message on the screen. Log the message to a file if the enableLogging has been called. 

The function have two interfaces, one who takes string text from string tables. And one that takes the text direct from the arguments.

Example:

ccError oError;
SetLastError( ERROR_FILE_NOT_FOND );
oError.error();
oError.error( CCEM_ERROR_NUMBER, ERROR_FILE_NOT_FOND );
oError.error( "File Not Found", "Can not open the file, cause" );
if ( 

     oError.error( CCEM_ERROR_MESSAGE, IDS_WANT_TO_DELETE_FILE, 

                   NULL, NULL, MB_YESNO  == IDYES 

   ) ...

 

ccError::enableErrorWnd

void enableErrorWnd( BOOL abEnable = TRUE)

Return Value:

None

Arguments:

abEnable

If  true the error window will be showed when error is called. If  false the error window will be disabled.

Remarks:

Handles if the Error window should be displayed when error is called. 

Example:

ccError oError;

oError.enableErrorWnd();