473,320 Members | 2,003 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,320 software developers and data experts.

Question about exceptions

Hello Group
I have a button click sub, which calles a function called 'send'
to send over a tcp connection. This function can call an
exception. If an exception occurs, I need to quit the button
click function. My problem is how do I propagate the
exception from the 'send' function, to the parent function
(the button click function).
Thanks (I have not done this sort of thing before)
(unless the way it to simply use return codes and test them,
like in api programming)
Aug 10 '07 #1
4 1055
Lawry wrote:
I have a button click sub, which calles a function called 'send'
to send over a tcp connection. This function can call an
exception. If an exception occurs, I need to quit the button
click function. My problem is how do I propagate the
exception from the 'send' function, to the parent function
(the button click function).
You don't have to. It will propagate automatically until it's caught.

--
Göran Andersson
_____
http://www.guffa.com
Aug 10 '07 #2
You don't have to. It will propagate automatically until it's caught.

My question is this: if there is an exception in the nested sub, will it
return to the parent sub right away, or will it try to complete the
other lines in the sub first, e.g. if it was inside a for loop?
>
--
Göran Andersson
_____
http://www.guffa.com

Aug 10 '07 #3
Lawry wrote:
>You don't have to. It will propagate automatically until it's caught.

My question is this: if there is an exception in the nested sub, will it
return to the parent sub right away, or will it try to complete the
other lines in the sub first, e.g. if it was inside a for loop?
It will exit right away.

--
Göran Andersson
_____
http://www.guffa.com
Aug 10 '07 #4
it works through a so called chaining mechanism

Sub MethodA
Try
MethodB
catch ex as exception
'the error that took place in MethodC is handled in this method
'if there was no exception handler here the program will crash
End try
'all code here will run if the catch has no exit sub
end sub

Sub MethodB
MethodC
'all code here is never touched exit takes place at the exception origin
line
end sub
Sub MethodC
'''''''''' exception here """"""""
all code here is never touched exit takes place at exception line
end sub

This is the reasson why i have the opinion that rethrowing exceptions is
never valid for the sole reasson of throwing it to the next call level ( i
think it is foolish )
as the chaining mechanism will take care of it automaticly and much more
efficient with a lot more exception details


<Lawryschreef in bericht news:u2****************@TK2MSFTNGP06.phx.gbl...
Hello Group
I have a button click sub, which calles a function called 'send'
to send over a tcp connection. This function can call an
exception. If an exception occurs, I need to quit the button
click function. My problem is how do I propagate the
exception from the 'send' function, to the parent function
(the button click function).
Thanks (I have not done this sort of thing before)
(unless the way it to simply use return codes and test them,
like in api programming)


Aug 11 '07 #5

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

Similar topics

0
by: David M. Wilson | last post by:
Hello! I maintain a small package for talking to the API of BulkSMS.co.uk. I have been adding support for some new features recently, and found myself slightly indecisive over how best to lay...
4
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category...
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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

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.