|
-
June 15th, 2001, 12:36 PM
#1
How to raise VB COM exceptions?
Is there any way in a COM object method to trap an error triggered by calling another COM object and raise an exception of its own? Here is the scenario:
A client calls MyObject.Connect (which is a VB COM object) passing parameters to connect to a database. MyObject calls ADODB.Connection.Open, which may raise an error. What I want is collect information from the Err object (i.e. source, number, and description), generate more detailed error string (such as "Cannot connect to database on server as user because of error Err.Number in Err.Source: Err.Description "), and raise error with my error code and generated error message.
I can do it in C++ using IErrorInfo interface, but cannot figure out how to do the same in VB. I tried to disable error handling (On Error GoTo 0)before raising error, but COM client did not get the error I raised.
Any hints are greatly appreciated. Thank you.
VB Newbee
-
June 15th, 2001, 01:45 PM
#2
Re: How to raise VB COM exceptions?
You can either
1) Raise an event from your component (like an ErrorEvent) and have the client catch that
2) Return a structure with detailed info for your client from the method that makes the ADODB connection.
HTH
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|