Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get VFP OLE Server to use error procedure
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00097111
Message ID:
00097402
Views:
24
>>I'm not sure if it's even safe to launch MessageBox() from the server.
>
>Really? Why?
>
>
>>The server I'm working on hse to sit there 24x7 logging realtime data so it has to do all it can survive errors. I think you'll just have to seed conditional code around the parts that can error out to skip the rest of the processing. The Error method can set a nLastError property that could be tested after each line that can give you errors and conditionally return the error to the client. I don't really know of a way to rollback the entire callstack from inside the error method. There isn't really a MASTER to return to since you are just running the method the client requested. I've got code like this in my server.
>
>I think you may be right here. It is unfortunate though. The last thing I want to do is test for an error every other line.
>
>What I ended up doing was using 'try...except' handler in Delphi. Like this. It actually works pretty well.
>
>try
> // Call the Method
> //
> s := oDataDll.GetARDataByDate(StartDate,EndDate);
> except
> // Method was canceled
> //
> on E: Exception do
> begin
> ShowMessage('An error occurred!');
> exit;
> end;
> end;
>
>If the method in the server gets CANCELled, the 'on E' code fires and I probably can write some code that explains a bit more about what had happened.
>
>This has been an experience. Thanks to all you guys for all your help.

Great thread--thanks for the question.

I think return to master would work if you made your clients call a single method, passing a string with the method (and any parameters) they want to call, but that's a pretty ugly approach.

I know in some of Bob Greens' sample code from last DevCon, his server had a property called "LastErrMsg" or something of that nature. You could use that approach to give your users a more descriptive error message.

I'm curious--how does Delphi know the server cancelled? Issueing a CANCEL in the error method is sufficient?

Finally, (I'm sure you have this covered) when cancelling from the error routine make sure to rollback any transactions and revert any buffered changes.
----------
Mark Bucciarelli
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform