Can we throw exception from catch Block?
Answers were Sorted based on User's Feedback
Answer / deepika
The above answer is wrong.We can absolutely throw
exceptions in catch blocks.This is called bubbling the
exceptions to one level higher.If catch block can not
handle exceptions,then it can throw the exception that it
caught, to it's caller
| Is This Answer Correct ? | 46 Yes | 1 No |
Yes. we can throw the exception from the catch block.
If anyone have confusion then try this code:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Test();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
private void Test()
{
try
{
throw new Exception("Dev");
}
catch (Exception ex)
{
throw ex;
}
}
| Is This Answer Correct ? | 40 Yes | 2 No |
Answer / manee
we can throw the exception in catch block by using throw New
Exception("Exception Message")
| Is This Answer Correct ? | 24 Yes | 2 No |
Answer / kakarala sowjanya
You can catch exceptions when the purpose of catching the
exception is to re-throw or transfer the exception to a
different thread. so we can throw exception from catch block
| Is This Answer Correct ? | 22 Yes | 1 No |
Answer / kamlesh sharma
yes we can through exception If catch block can not
handle exceptions,then it throw the exception to it's
caller
| Is This Answer Correct ? | 16 Yes | 2 No |
Answer / subbarao
i think answer is NO, because catch block is used to catch
the exceptions thrown
| Is This Answer Correct ? | 9 Yes | 69 No |
What is csrf attack in asp.net?
what is an Eventbubbling?
In asp.net application, if a webpage or total application seems too slow or getting delayed to load completely in the browser. As a developer, what are the checkings or actions you will take in the application or server side to rectify the slowness or delay load or which are the factors related to this issue? How we can trace it?
What is the differences between a primary key and a unique key in sql server?
What is a swagger in web api?
Define WCF ABC , Diffrent Contract. Diff b/w Wcf and in webservice
What are sessions used for?
What is runtime host ?
What is Razor View Engine
what is service contract,operation contract?
Is it right that ASP.NET Web API has replaced WCF?
How to rename a table using sql queries?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)