Linked Questions

8 votes
1 answer
9k views

Is it normal to re-throw, after some action, an exception from around aspect to ExceptionHandler in rest controller, like this: @Around("execution(* *(..)) && @annotation(someAnnotation)") ...
Alrail's user avatar
  • 83
0 votes
2 answers
807 views

Note: This is a question from the PHP perspective for C#. Maybe it isn't the right way to do it, but here is what I'm trying to do. Suppose you have defined: void Die(string error){ print(error); ...
ina's user avatar
  • 19.6k
-4 votes
1 answer
220 views

I don't understand the sense of error handling with try and catch. (C#) In my online course the following example was used: class Program { static void Main(string[] args) { try ...
Krunki's user avatar
  • 5
312 votes
11 answers
197k views

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 ...
Seibar's user avatar
  • 70.6k
211 votes
6 answers
27k views

We were discussing with our coworkers on what it means if the method name starts with "Try". There were the following opinions: Use "Try" when the method can return a null value. Use "Try" when the ...
ms007's user avatar
  • 4,781
116 votes
4 answers
32k views

Alright, this is an easy one: What's the difference between Application.ThreadException and AppDomain.CurrentDomain.UnhandledException? Do I need to handle both? Thanks!
JohnIdol's user avatar
  • 50.4k
33 votes
6 answers
27k views

I have "inherited" a little C# method that creates an ADO.NET SqlCommand object and loops over a list of items to be saved to the database (SQL Server 2005). Right now, the traditional SqlConnection/...
marc_s's user avatar
  • 760k
4 votes
11 answers
1k views

I'm trying to avoid returning an incorrect value when in the catch but I'm having trouble finding a better solution than this: private SecurityLevel ApiGetSecurityLevel() { try ...
Robert's user avatar
  • 6,236
4 votes
3 answers
17k views

I'd like to know if the use of ApplicationException is recommended to return application errors when a user breaks some business rule. For example: public void validate(string name, string email) { ...
Fabio Belz's user avatar
8 votes
6 answers
855 views

I have some code that currently looks somewhat like this: public void MainFunction() { try { SomeProblemFunction(); } catch { AllFineFunction(); } } private void ...
frenchie's user avatar
  • 52.3k
1 vote
5 answers
8k views

According to this answer: https://stackoverflow.com/a/1722991/680026 you should only use try-catch if you really do something there besides logging: Don't catch an exception if you're only going to ...
Ole Albers's user avatar
  • 9,399
4 votes
2 answers
10k views

In my application, I want to send logs in case of crash to remote server. I have added try-catch block and in catch I'm sending logs to server. I want to know what all exceptions should I catch. I ...
dn_c's user avatar
  • 614
6 votes
2 answers
3k views

In Javascript you can delete an object property: var o = { x: 1, y: 2 }; var wasDeleted = delete o.x; Now o.x should be undefined and wasDeleted is true. However you can only delete native objects, ...
Keith's user avatar
  • 157k
1 vote
3 answers
2k views

In a Visual Studio 2010 C# Project, how do I find out if any method is written without having a try-catch block? Sometimes as a code reviewer, its hard to search function/methods which are not ...
Mazhar Karimi's user avatar
1 vote
2 answers
4k views

If I want to put the connection in an external file, what part of this code should be in that external file? $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "podcast"; ...
Nrc's user avatar
  • 9,871

15 30 50 per page