Passing an Exception to a Sub? 
Author Message
 Passing an Exception to a Sub?

it is possible to pass an exception to a external sub? i mean..... ie.

I have a process, or sub, or function or whatever that have an Try Catch
EndTry, and in the catch i want to do something like
Try
Catch e1 as exception
 AnError(e1)
End Try

and then, make a sub to display and handle that exception in the screen

Sub AnError(byval ex as exception)
 msgbox ex.message.tostring
 msgbox ex.tostring
 ...and so on, i'll basically build a custom form here where i will display
the error
End Sub

My question is if passing an exception like that way will work ?



Sat, 29 Jan 2005 23:25:58 GMT  
 Passing an Exception to a Sub?
As an exception is nothing more or less than a class, you definitely can.  I
do this all the time in a trace/logging routine that I use.

HTH

David


Quote:
> it is possible to pass an exception to a external sub? i mean..... ie.

> I have a process, or sub, or function or whatever that have an Try Catch
> EndTry, and in the catch i want to do something like
> Try
> Catch e1 as exception
>  AnError(e1)
> End Try

> and then, make a sub to display and handle that exception in the screen

> Sub AnError(byval ex as exception)
>  msgbox ex.message.tostring
>  msgbox ex.tostring
>  ...and so on, i'll basically build a custom form here where i will
display
> the error
> End Sub

> My question is if passing an exception like that way will work ?



Sat, 29 Jan 2005 23:57:27 GMT  
 Passing an Exception to a Sub?
An exception is an object and can be passed as an argument like any other
object.

John Hamby, VB.Net

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> it is possible to pass an exception to a external sub? i mean..... ie.

> I have a process, or sub, or function or whatever that have an Try Catch
> EndTry, and in the catch i want to do something like
> Try
> Catch e1 as exception
>  AnError(e1)
> End Try

> and then, make a sub to display and handle that exception in the screen

> Sub AnError(byval ex as exception)
>  msgbox ex.message.tostring
>  msgbox ex.tostring
>  ...and so on, i'll basically build a custom form here where i will
display
> the error
> End Sub

> My question is if passing an exception like that way will work ?



Sun, 30 Jan 2005 03:27:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing a sub name to another sub

2. Passing as string variable from sub to sub

3. Fail to catch exception in sub main

4. Exception when passing structure as a Win API parameter

5. menus and sub-menus and sub-sub-menus

6. count elements in root, sub root sub-sub root treeview

7. Catch Exception Compluss Exception Code

8. Passing Value from Module Function to Form sub problem

9. Passing Recordset to Sub or Function

10. Passing variables from VBA sub to VB scipt

11. Passing Userforms to subs (Word 2000 and 2002, I did not try Word 97)

12. Pass shape name to macro or to a vb sub

 

 
Powered by phpBB® Forum Software