473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Get object which created the Exception

Hi,

I want to know which object created an instance of my custom exception
class. For example I want to know in the DummyException class the ID
of the User, when an instance of the DummyException class is created.
I don't want to pass the ID of the user, because different types of
object can create the DummyException class, and based on the type I
want to perform different types of operations.

Johan.

Sample code:

Public Class User
Private _ID As String
Public Property ID() As String
Get
Return _ID
End Get
Set(ByVal Value As String)
_ID = Value
End Set
End Property
Public Sub ShowMessage()
Throw (New DummyException("Some error message"))
End Sub

End Class
Public Class DummyException
Inherits ApplicationException

Private _UserID As String

Public Sub New(ByVal message As String)
MyBase.New(message)

'TODO: Retrieve the calling object, to get the ID of the user.
End Sub
Public ReadOnly Property UserID() As String
Get
Return _UserID
End Get
End Property
End Class
Nov 20 '05 #1
0 798

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
2
by: CoolPint | last post by:
Standard exception classes in C++ have what() which returns const char * and they have constructors accepting string. Where is that string created and when is the string destroyed? In the...
4
by: Zork | last post by:
Hi, I am trying to stop object creation (in this case ill use a ball as the object) via use of exceptions. In essence, if the ball does not have an owner, I do not want the ball object created....
8
by: Sam | last post by:
Hello I was wondering is it possible to refuse the creation of an object. For example if the user doesn’t enter a correct string (as a parameter in the constructor), could the object refuse to...
0
by: Siegfried Heintze | last post by:
This program works fine on my desktop when I grant full control of the MSAccess database to everyone. However, when I put it on my hosting service with no impersonation, I now get this error (see...
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
6
by: Rufnex | last post by:
Hi, is there a delete for a object inside the constructor, while i init it? i will try something like that: var obj = function(a) { if (!a) delete this; this.a = a; }
3
by: pkolinko | last post by:
Hi everyone, I am writing a small low level embedded USB application using C++/CLI windows Forms. I am sort of new to the C++/CLI and having trouble understanding what happens in this very...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
7
by: j.l.olsson | last post by:
Hello, I am using std::auto_ptr to try to keep ownership of resources straight. However, I became aware that exception objects must provide a copy constructor, which made me uncertain of the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.