Author | Topic: Automation Errors | |
---|---|---|
Regan Cawkwell | Automation Errors on Wed, 06 Apr 2016 09:37:30 +0100 Hi everyone. Does anyone have an easy set of code that converts the huge negative error codes that you get when something goes wrong in an ActiveX process into something more meaningful? Thanks. Regan Cawkwell Developer ------------------------------- Real Business Applications Ltd ------------------------------- | |
Jim Lee | Re: Automation Errors on Wed, 06 Apr 2016 23:56:59 +0200 > Does anyone have an easy set of code that converts the huge negative error > codes that you get when something goes wrong in an ActiveX process into > something more meaningful? #define FORMAT_MESSAGE_FROM_SYSTEM 0x00001000 FUNCTION FormatErrorMessage( nError ) LOCAL cMessage := SPACE(512) DEFAULT nError TO GetLastError() @Kernel32:FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM,; 0 ,; pointer to message source nError ,; message ID 0 ,; language ID (default) @cMessage ,; pointer to message buffer 512 ,; max size of message buffer 0 ) address of array of Message inserts cMessage := LTRIM(STR(nError)) + " = " + cMessage RETURN TRIM(cMessage) FUNCTION GetLastError() LOCAL rc := 0 rc := @Kernel32:GetLastError() RETURN rc | |
Regan Cawkwell | Re: Automation Errors on Thu, 07 Apr 2016 09:13:21 +0100 Thanks Jim, that looks good. Do you just call this function if the error subsystem is 'Automation'? Regan Cawkwell Developer ------------------------------- Real Business Applications Ltd ------------------------------- On 06/04/2016 22:56, Jim Lee wrote: >> Does anyone have an easy set of code that converts the huge negative error >> codes that you get when something goes wrong in an ActiveX process into >> something more meaningful? > > #define FORMAT_MESSAGE_FROM_SYSTEM 0x00001000 > > FUNCTION FormatErrorMessage( nError ) > LOCAL cMessage := SPACE(512) > > DEFAULT nError TO GetLastError() > @Kernel32:FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM,; > 0 ,; pointer to message source > nError ,; message ID > 0 ,; language ID (default) > @cMessage ,; pointer to message buffer > 512 ,; max size of message buffer > 0 ) address of array of Message inserts > cMessage := LTRIM(STR(nError)) + " = " + cMessage > RETURN TRIM(cMessage) > > FUNCTION GetLastError() > LOCAL rc := 0 > rc := @Kernel32:GetLastError() > RETURN rc > > > |