Last post Sep 20, 2014 12:28 PM by gerrylowry
Sep 20, 2014 11:51 AM|agentvnod|LINK
What is exception bubbling and in real time where we use this concept and also what is the need to use bubbling up the exceptions ? I am very much confused with bubbling the exceptions why because i have gone through many sites no one has given clear
idea about that , and also i have a doubt with what is the diff. b/w Catch; Catch e
Sep 20, 2014 12:28 PM|gerrylowry|LINK
@agentvnod welcome to forums.asp.net
it's not just a .NET Framework concept ... it's not even unique to the windows platform.
generally, when a error occurs that causes some form of hardware related fault, or when a program has a situation that it does not want to process, either the operating system or the programmer causes an exception to be thrown.
analogy in real life from the technical support paradigm (read the below upwards from (h) to (a):
(a) i call the president of HP Canada
(b) Canadian Support Manager will not honour promise of Costa Rican supervisor
(c) Costa Rican supervisor promises to fix my issue but needs permission from (b), above.
(d) Costa Rican level 2 support can not resolve issue.
(e) Costa Rican level 1 support technician causes my registry to get mang(led.
(f) i call HP technical support in Costa Rico
(g) i have a support issue that i can not solve by myself
(h) i accept Microsoft's invitation to upgrade my Windows 8 to8.1 for free.
The above (a) to (h) is analogous to what we know as a call stack ... when an issue that can not be processed happens deep within an executing computer program, it starts to bubble up; as it bubbles up, there are many opportunities to catch and process the
Example: zero divide is an illegal operation.
x / y will cause a zero divide exception when y == 0
if c#, we catch exceptions with try/catch blocks.
when we catch an exception, for many types of exceptions, we can (a) process the exception, (b) ignore the exception, or (c) process the exception and pass it further up the call stack (like step (c) in my analogy).
agentvnod, you need to study
http://msdn.microsoft.com/en-us/library/5b2yeyab%28v=vs.110%29.aspx "Handling and Throwing Exceptions" and related articles.
if you've every experienced your system simply locking up solid, that's an exception that no one caught; OTOH, the "blue screen of death" is an exception that Windows caught but was not able to handle.
for the second part of your question, please study this:
http://msdn.microsoft.com/en-us/library/0yd65esw.aspx "try-catch (C# Reference)"
N.B.: "Although the catch clause can be used without arguments to catch any type of exception, this usage is not recommended."