Linked Questions

556 votes
9 answers
252k views

Is it better to do this: try { ... } catch (Exception ex) { ... throw; } Or this: try { ... } catch (Exception ex) { ... throw ex; } Do they do the same thing? Is one better ...
Patrick Desjardins's user avatar
26 votes
8 answers
37k views

I'm wondering what the correct way is to pass on an exception from one method to another. I'm working on a project that is divided into Presentation (web), Business and Logic layers, and errors (e.g. ...
avesse's user avatar
  • 781
0 votes
4 answers
180 views

Given the following statements: try { ... some code ... } catch { ... some cleanup code ... throw; } and try { ... some code ... } catch (Exception ex) { ... some cleanup code ......
Scottie's user avatar
  • 11.4k
-2 votes
2 answers
850 views

I have a query handler decorator which logs any exceptions: public class QueryHandlerLogDecorator<TQuery, TResult> : IQueryHandler<TQuery, TResult> where TQuery : IQuery<TResult>...
Graham's user avatar
  • 1,527
-1 votes
1 answer
115 views

I'm curious to find out what the best practice is for caught exceptions that aren't used. The irony is that this is going against best practice in the first place. I've found myself in a position to ...
MacSalty's user avatar
  • 1,272
0 votes
1 answer
193 views

I am developing a program for my final project of college that consists of taking several SQL scripts from a fixed folder and executing them. In a meeting with my project supervisor he said that it ...
Henrique Moreira's user avatar
0 votes
1 answer
142 views

Possible Duplicate: .NET - Throwing Exceptions best practices Hi, I have seen people re-throwing exceptions as given below. which one is optimal? Why one mechanism is optimal than the other one. ...
Maanu's user avatar
  • 5,223
0 votes
0 answers
35 views

What are key words from throw exeption like this? public void methodOne() throw SomeExeption { try{ doSomething(); catch(SomeExeption se) { throw se; } } public void ...
user avatar
374 votes
12 answers
115k views

I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it? I am rethrowing the InnerException, ...
skolima's user avatar
  • 32.9k
215 votes
15 answers
377k views

while maintaining my colleague's code from even someone who claims to be a senior developer, I often see the following code: try { //do something } catch { //Do nothing } or sometimes they write ...
Toan Nguyen's user avatar
  • 11.6k
230 votes
13 answers
330k views

What is the difference between try { ... } catch{ throw } and try{ ... } catch(Exception e) {throw new Exception(e.message) } regardless that the second shows a message.
Strider007's user avatar
  • 4,995
32 votes
5 answers
37k views

This is a follow-up question to Is there a difference between “throw” and “throw ex”? is there a way to extract a new error handling method without resetting the stack trace? [EDIT] I will be trying ...
dance2die's user avatar
  • 37.2k
10 votes
11 answers
25k views

I've got a class that calls a SOAP interface, and gets an array of data back. However, if this request times out, it throws an exception. This is good. However, I want my program to attempt to make ...
psyklopz's user avatar
  • 2,401
24 votes
5 answers
29k views

We have a service which will log unhandled exceptions at the app domain level (via Log4net). We logged: 2014-01-28 16:49:19,636 ERROR [49] FeedWrapperService - unhandled System....
Skym's user avatar
  • 836
17 votes
5 answers
56k views

internal static string ReadCSVFile(string filePath) { try { ... ... } catch(FileNotFoundException ex) { throw ex; } catch(Exception ex) { ...
Anubhav Ranjan's user avatar

15 30 50 per page