Linked Questions
29 questions linked to/from Difference between 'throw' and 'throw new Exception()'
70 votes
5 answers
26k views
What does "throw;" by itself do? [duplicate]
Possible Duplicate: difference between throw and throw new Exception() What would be the point of just having catch (Exception) { throw; } What does this do?
7 votes
4 answers
2k views
Using "Throw" in a catchblock (and nothing else!) [duplicate]
Possible Duplicate: difference between throw and throw new Exception() I'm a programmer working on adding new functionality to legacy code. While debugging, I parsed over this Catch block, which ...
0 votes
4 answers
180 views
Are these 2 try/catch/throw statements the same? [duplicate]
Given the following statements: try { ... some code ... } catch { ... some cleanup code ... throw; } and try { ... some code ... } catch (Exception ex) { ... some cleanup code ......
566 votes
13 answers
304k views
Is there a difference between "throw" and "throw ex"?
There are some posts that asks what the difference between those two are already. (why do I have to even mention this...) But my question is different in a way that I am calling "throw ex" in another ...
312 votes
11 answers
197k views
Best practices for catching and re-throwing .NET exceptions
What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a ...
42 votes
6 answers
18k views
What is the difference between throw e and throw new Exception(e)?
Consider: try { // Some code here } catch (IOException e) { throw e; } catch (Exception e) { throw e; } What is the difference between throw e and throw new Exception(e)? try { // ...
36 votes
6 answers
12k views
Wrong line number on stack trace
I have this code try { //AN EXCEPTION IS GENERATED HERE!!! } catch { SqlService.RollbackTransaction(); throw; } Code above is called in this code try { //HERE IS CALLED THE METHOD THAT ...
2 votes
2 answers
8k views
Invalid column name exception
Im trying to get a simple SQL statement in my code, and get a DataTable, and for some reason I get this weird exception : Invalid column name This is my code : public DataTable GetAllVideoID(...
3 votes
1 answer
3k views
What method of EF 6 is better to use for get data from database async?
I have next code public async Task<IEnumerable<MyTabel>> GetData() { try { var dbCtx = new myEntities(); return await dbCtx....
3 votes
3 answers
5k views
Good practice design pattern for Exception handling
I have exception handling code in every method for the below code for the bottom level methods throw new Exception("The error that happens"); Is there any way I can avoid writing this code again and ...
0 votes
4 answers
2k views
Syntax error in INSERT INTO statement
I wrote a program that connects to MS Access. When I fill in the fields and add a new item to Access the program fails. The exception is "Syntax error in INSERT INTO statement" Here is the relevant ...
0 votes
3 answers
2k views
C# asynchronous method - help needed
I have an asynchronous method that consumes a Web API action. It appears to be stuck in a loop. My reasoning for this is because if I put a break point on line 1 of the catch block, and step into, it ...
1 vote
2 answers
7k views
How to return data from the database using 3 tier architecture structure using ASP.NET C#
Let's say I have a 3-tier ASP.NET application written in C#. How are you supposed to utilize the DAL, BLL and PL correctly? For example let's say I have a stored procedure which requires a parameter ...
0 votes
2 answers
2k views
Saving/Loading Using()/Try-Catch
I've been digging around the past couple hours on how to implement simple save/load functionality to a game i'm making. The save data is being stored in a text file, during the game the player can ...
0 votes
1 answer
6k views
how to properly use: System.InvalidOperationException
This is Unity C# //... public static void Interupt(int Index, string Text){ try{ Change(Transforms[ Index ], Text); } catch{ throw new System....