Solved

Trapping errors from Business Tier DLL

Posted on 2001-06-21
11
330 Views
Last Modified: 2010-05-02
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?

0
Comment
Question by:redundguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6213912
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
 
LVL 1

Expert Comment

by:barendb
ID: 6213913
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 6213914
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 15

Expert Comment

by:ameba
ID: 6213977
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
 
LVL 1

Author Comment

by:redundguy
ID: 6214055
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
 
LVL 6

Expert Comment

by:simonbennett
ID: 6214058
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
 
LVL 1

Expert Comment

by:morgan_peat
ID: 6214069
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 6214072
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
 
LVL 1

Author Comment

by:redundguy
ID: 6214182
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 133 total points
ID: 6214278
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
 
LVL 1

Author Comment

by:redundguy
ID: 6223993
Thanks to all
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access query that references subform 5 50
vb6 connector to mongodb 2 163
MS Access 03, TransferText, decimal places 8 92
Modify Text File with Excel Macro 13 50
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question