Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Mapimail.vcx
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00477327
Message ID:
00485236
Views:
43
Hi Nigel.

Long time no see! How's by you?

>> Preventing errors in the class will infringe on higher level error handlers. <<

Sorry, but I really have to disagree with you here. If errors occur while getting or sending e-mail, it is the class's responsibily to deal with them if it can.

That can mean a number of different things. It may mean passing it up to the object it is sitting on or it may mean just adding it to an interenal error collection that can be accessed the object that is using its services like so:

This code in the error method:

*** log the error
This.LogError( nError, MESSAGE(), cMethod, MESSAGE(1), 2 )

This code in LogErrors:
LOCAL lnErrCnt
WITH This
    *** How many Errors currently?
    lnErrCnt = ALEN( .AErrors, 1 )
    *** If only one row, is it actually an error?
    IF lnErrCnt = 1 AND EMPTY( .Aerrors[ 1, 1 ] )
        *** Nope - set error count = 1
        lnErrCnt = 1
    ELSE
        *** We already have at least one error, 
        *** so increment the counter
        lnErrCnt = lnErrCnt + 1
    ENDIF
    *** Re-Dimension the Collection
    DIMENSION .AErrors[ lnErrCnt, 5 ]
    *** And Populate the current row 
    .AErrors[ lnErrCnt, 1 ] = tnErrNum
    .AErrors[ lnErrCnt, 2 ] = IIF( EMPTY( tcErrMsg) , "", ALLTRIM( tcErrMsg ) )
    .AErrors[ lnErrCnt, 3 ] = IIF( EMPTY( tcMethod) , "", ALLTRIM( tcMethod ) )
    .AErrors[ lnErrCnt, 4 ] = IIF( EMPTY( tnLineNum) , "", ALLTRIM( PADL( tnLineNum, 100 )) )
    .AErrors[ lnErrCnt, 5 ] = IIF( EMPTY( tnSeverity) , "", ALLTRIM( PADL( tnSeverity, 100 )) )
ENDWITH
*** Just Return Success!
RETURN .T.
In order to see why a method of the MAPI class failed, the caller would merely call the class's GetErors method and take appropriate action. Code like this in GetErrors:
LOCAL lnErrCnt, loParamObj, lcErrName, lcErrDets, lnCnt

*** Create the parameter object
loParamObj = CREATEOBJECT( 'relation' )

*** Check if we have any errors
lnErrCnt = ALEN( This.AErrors, 1 )
IF lnErrCnt = 1 AND EMPTY( This.AErrors[1,1] )
    *** No Errors Pending
    loParamObj.AddProperty( 'nErrorCount', 0 )
ELSE
    *** Populate the Parameter Object here
	WITH loParamObj
        .AddProperty( 'nErrorCount', lnErrCnt )
        .AddProperty( 'aErrors[1]', "" )
        *** Now Get the 5 Logged Details
        FOR lnCnt = 1 TO lnErrCnt
            *** Add a row to the error array
            DIMENSION .aErrors[lnCnt, 5]
            *** Log the error as Character Strings
            .aErrors[lnCnt, 1] = TRANSFORM( This.AErrors[ lnCnt , 1] )    && Error Number
            .aErrors[lnCnt, 2] = TRANSFORM( This.AErrors[ lnCnt , 2] )    && Error Message
            .aErrors[lnCnt, 3] = TRANSFORM( This.AErrors[ lnCnt , 3] )    && Prog/Method
            .aErrors[lnCnt, 4] = TRANSFORM( This.AErrors[ lnCnt , 4] )    && Code Line
            .aErrors[lnCnt, 5] = TRANSFORM( This.AErrors[ lnCnt , 5] )    && Severity
	    NEXT
    ENDWITH
ENDIF
*** Clear the Error Collection
DIMENSION This.AErrors[1,5]
This.AErrors = ""
*** Return Errors
RETURN loParamObj
I don't think that code like this woould interefere with anything < s >.

Marcia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform