Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom exceptions

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
In vb

I have written custom exception classes that inherit my custom exception obj ...


Public MustInherit class JobException
Inherits customException
'constructor
Public sub new(ExceptionID, Message , AppMessage, User , JOB)


then I have a class....

Public Class InvalidJobTypeJOB
Inherits JobException
'constructor
public sub new
(JobTypeJOB as JobTypeJOB, AppMessage as string , CurrentUser as User)

MyBase.new( ErrorCode.InvaidJOB , "Invalid JOB" ,
AppMessage , Currentuser, JobTypeJOB.JOB )

My problem is JOB can be null (it may not exsist yet)
... It is bad when an exception throws an exception ... null pointer

Now c# has a condional operator I could use but I have 900 lines of vb code here. what a let down

Thoughts?





 
Where is the exception being thrown?

Can you do
public sub new
(JobTypeJOB as JobTypeJOB, AppMessage as string , CurrentUser as User)
Dim objJob as JobTypeJob
if JobTypeJob is nothing then
objJob = New JobTypeJob
..... set dummy properties
else
objJob = JobTypeJob
End if

MyBase.new( ErrorCode.InvaidJOB , "Invalid JOB" ,
AppMessage , Currentuser, objJob.JOB)
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
John,

Thanks for the reply :)

I have a sub procedure that does a sql call and populates a collection of objs .. if the connection can not be made I throw this
Try
SqlSelect(JOBID)
Catch ex As Exception
Throw New InvalidJOB(p1,p2,p3,p4...)
EndTry

That is what I am looking for... I think.. I will try it..

If IsNothing(JOBTypeJOB) then
.....create obj and set params
End If
MyBase.new(blah blah blah)


I didn't know you could do this in a constructor before calling the myBase.new()

I did have another thought.. I could go to each obj and write a another constructor .. don't really like that idea ..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top