Trapping errors from Business Tier DLL

I develop a three tiers application in VB6, client-server architecture.
The User interface tier is a VB6 EXE project. The Business tier is a VB6 Active X COM project (DLL) that has some classes.
The data are introduced by a VB form of User interface tier, but is validated in Business tier?s property functions.
When a data isn?t OK (wrong data), I have to write a message on the screen and retry the data input flow in the User interface tier input procedure.
My problem is:
How can Business object tier procedure to tell User interface tier procedure that there are an error (and it have to retry the data input).
I have try to use err.Raise in Business tier procedure, but User interface tier procedure isn?t interrupted by an error:
On Error goto err:
     Object.member=value     ?call the property function of member of object.
     ?The property contains err.Raise
     Msgbox ?is ok?
     Exit sub
Err:
     Msgbox ?I was interrupted by an error?
     End sub
I see ?is ok?.
Is this unpleasant situation related to the following sentences from MSDN Library Visual Studio 6.0 help: ?System errors during calls to Windows DLL do not raise exceptions and cannot by trapped with Visual Basic Error trapping? ?
How can I trap validation errors from Business object tier procedure?

LVL 1
redundguyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
I think the problem is a VB IDE setting:
Check out the "Break on..." settings in your options,
where you can set to one of these:
* Break on all errors (which is set, i guess)
* Break in Class module
* Break on unhandled errors

Note that the last one behaves as if you compiled the application....

Cheers
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
A simple Err.Raise will not be enough, i must contain at least a non-zero error number:
Err.Raise 994349
Additionally, you can supply the Description, source aso

The info you read from the Windows DLL is different: the code in there will not raise exceptions, but give you return codes, which indicate if the code has executed successfully or not.

Cheers
0
 
barendbCommented:
redundguy,

You'll have to use a method in the DLL part to pass the data to the DLL, validate it and return a value to the EXE if data was accepted or not, you can even return a UDT with the error value (if any) and the value that returned the error.

Hope this helps.

Barend
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
CJ_SCommented:
Should work properly IMHO.

Err.Raise vbObjectError + 512

Regards,
CJ

(ps. if you write something in word anc copy / paste it, the single quote will be changed the a question mark, as you can see in your question :-)..)
0
 
amebaCommented:
Last 10 Grades Given:  A B C    :-(

Before raising the error, *always* include "On Error GoTo 0" line.

' this DOES NOT work
Public Property Let Phone1(ByVal NewValue As String)
    On Error Resume Next
    If NewValue = "" Then
        Err.Raise 5
    End If
End Property

' this works OK
Public Property Let Phone2(ByVal NewValue As String)
    If NewValue = "" Then
        On Error GoTo 0
        Err.Raise 5
    End If
End Property

Note: Do not accept my comment 'as answer' if it is not for A grade!
0
 
redundguyAuthor Commented:
Angellll, I have used the number. (1001)
CJ_S, it doesn?t work
Ameba, it doesn?t work.
 
Sorry, I was incorrect. I saw the message
 ?Run time error 1000? when I expected to see:
?I was interrupted by an error?.
0
 
simonbennettCommented:
Everyone is right, it should work, unless you are jumping out of scope within your error handler. Only alternative is to raise an event in the server e.g.

Public Event ValidationFailed(byval theError as Error)

...and then trap it in the client

Public Withevents MyObject

Public Sub MyObject_ValidationFailed(byval theError as Error)
   err.raise theError.Number ' and the other error properties!

end sub

HTH and good luck

Simon
0
 
morgan_peatCommented:
In your business-tier DLL, you need to have 'unattended execution' checked in the project properties dialog box.
This will ensure that any errors raised get sent back to the calling DLL.

If you still can't get it to work, post the code in your property Let procedure up and we can have a look at that.
0
 
CJ_SCommented:
Please show how you are raising the error, and the error handling in the function where you raise the error. Then please also show how the error handling is done at the client. That will give us a better view of what you are currently doing.

regards,
CJ
0
 
redundguyAuthor Commented:
The error is raised in BO tier Property procedure with:
   err.Raise 1000.
The error is handled only in UI tier procedure with the code I have already shown.
Thanks to all!
I'm sory, I have to go out. We'll see tomorow!
0
 
redundguyAuthor Commented:
Thanks to all
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.