Answered error class

  • lunedì 27 febbraio 2006 18:48
     
     

    I copied a few lines of code from a sample _error.scx I think to the INIT of my form to handle and report errors. It seems to be working fine at design time when I execute the form and play with it. It even reports errors (dumps them into an error.log file) when I build app or exec.

    What it does not do, and I expected it to do that, is to show me errors when I try to run the exec just built. I get errors "feature not found" and I want to know where they are, I mean from what part of executable code they come about.

    Is it a reasonable expectation to get this information? How shall I change the parameters of the BUILD command to get it if it is at all possible?

    Thanks.

    #DEFINE C_NOCLASS_LOC "Error class library (_APP.VCX) not found."

    DODEFAULT()

    LOCAL lcFile

    THISFORM.cOldError=ON("ERROR")

    lcfile = HOME()+("FFC\_app.vcx")

    IF NOT FILE(lcfile)

    WAIT WINDOW C_NOCLASS_LOC TIMEOUT 3

    RETURN .F.

    ENDIF

    PUBLIC cusError

    cusError = NEWOBJECT("_error",lcFile)

    ON ERROR cusError.Handle(ERROR(),PROGRAM(),LINENO())

Tutte le risposte

  • mercoledì 27 marzo 2013 08:13
    Proprietario
     
     

    Alex,

    Is this still an issue?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

  • mercoledì 3 aprile 2013 09:05
     
     Con risposta

    This is a classic situation you just take a little part of FFC (foxpro foundation classes) without basing your whole application on it.

    Or this is the classic situation of a dependency on a classlib (_app.vcx) not included in the project and the final exe, as it's only used indirectly.

    It's both.

    VFP build does not detect you need the _app.vcx in your exe, because it's path is put into a variable value (lcFile = HOME()+"FFC\_app.vcx") and then used with NEWOBJECT("_error",lcFile).

    Indeed you would need the _error class of the _app.vcx and whatever else that _app.vcx depends on as base classes. And the VFP compiler does not detect that, and doesn't include that into your EXE and into your project fiels. So it would be your responsibility as a developer to add that vcx and dependencies into your project.

    This is unnecessary, if you'd have used the application wizard and base the whole application on the FFC classes anyway, as that would have automatically added the _app.vcx and many more to your project.

    Besides that, your EXE would need to run that code to have that error handler in effect, it's the last line ON ERROR making this work globally. Even if you include _app.vcx and include this code as prg, it wouldn't work, you'd also need to run it to let ON ERROR get in effect.

    If you don't want to use the FFC application framework/wizard, which would be considered a good move, then also don't use parts of it, I'd rather suggest you build your own error handler, the topic ON ERROR has a good start at it. Also you can of course look into the _error class and especially it's Handle() method, which is what is called in case of an error, as the ON ERROR definition clearly sets it up.

    Bye, Olaf.


    Olaf Doschke (Setmics)