` Printed Icetips Article

Icetips Article



ABC: Overriding error class to log errors to file
1998-12-14 -- Joseph Lucas
 
Newsgroups: topspeed.products.c4

I have a conversion program which reads our clarion 2110 .dat files and
copies them to our SA database.  Here's what I do:

1) In Global properties, Classes tab, General button - I changed the
ErrorManager to AppErrors.

2) In Global properties, Embeds, After Global Includes - I added the
following:

AppErrors   CLASS(ErrorClass)
WriteError    PROCEDURE
                     END

3) In Global properties, Embeds, Program Procedures - I added the following:

AppErrors.WriteError PROCEDURE
  CODE
 Global:Error = SELF.SubsString()
 SELF.SetID(Msg:AddFailed)                         ! This Error message contains the
%ErrorText macro.
 ASC:Line=CLIP(ASC:Line) &' '& SELF.SubsString()   ! This method translates %ErrorText to
the
 ADD(AsciiFile)                                    ! pertinent ERRORCODE()&ERROR()
values.

4) In Global properties, Embeds, After File Declarations - I added the
following:

AsciiFile    FILE,DRIVER('ASCII'),NAME(LogFileName),PRE(ASC),CREATE
Record         RECORD,PRE()
Line             STRING(2048)
               END
             END

5) In my source procedure when I'm ready to write a record to the SA
database I use:

   IF Access:Dx.TryInsert()
     ASC:Line = '** DX ('&CLIP(DX:DxCode)&' '&DX:DxType&') File Error'
     GlobalErrors.WriteError
   END

6) In Setup, Application Options, Generation tab - Turn off (uncheck)
"Enable #ASSERT checking".


That should do it, let me know if I forgot anything.  HTH,

----------------------------------------------------------------
Joseph Lucas



Printed November 21, 2024, 6:39 am
This article has been viewed/printed 35388 times.
Google search has resulted in 18 hits on this article since January 25, 2004.