Skip to main content
55 votes
5 answers
26k views

I found that there are three ways to catch an exception, what are the differences? 1) catch by value; 2) catch by reference; 3) catch by pointer; I only know that catch by value will invoke two ...
skydoor's user avatar
  • 26.1k
361 votes
11 answers
301k views

I'm having a debate with a co-worker about throwing exceptions from constructors, and thought I would like some feedback. Is it OK to throw exceptions from constructors, from a design point of view? ...
lkristjansen's user avatar
  • 3,714
161 votes
7 answers
121k views

Why can't I just throw an Error inside the catch callback and let the process handle the error as if it were in any other scope? If I don't do console.log(err) nothing gets printed out and I know ...
demian85's user avatar
  • 2,534
140 votes
14 answers
31k views

In C++, you can specify that a function may or may not throw an exception by using an exception specifier. For example: void foo() throw(); // guaranteed not to throw an exception void bar() throw(...
1800 INFORMATION's user avatar
134 votes
7 answers
40k views

I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to ...
user avatar
60 votes
8 answers
66k views

Can any of you explain what the differences are between throw, throws and Throwable and when to use which?
Sumithra's user avatar
  • 6,725
89 votes
8 answers
58k views

I have been coding in Java for a while now. But sometimes, I don't understand when I should throw the exception and when should I catch the exception. I am working on a project in which there are lot ...
AKIWEB's user avatar
  • 19.9k
112 votes
3 answers
33k views

Is there any difference between throw() and noexcept other than being checked at runtime and compile time respectively? This Wikipedia C++11 article suggests that the C++03 throw specifiers are ...
iammilind's user avatar
  • 70.6k
663 votes
14 answers
602k views

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did throw new Error('sample') like in the following code try { throw ...
Jayapal Chandran's user avatar
62 votes
19 answers
115k views

When there is a post-condition, that return value of a method must not be null, what can be done? I could do assert returnValue != null : "Not acceptable null value"; but assertions could be turned ...
stratwine's user avatar
  • 3,699
43 votes
12 answers
8k views

I rethrow an exception with "throw;", but the stacktrace is incorrect: static void Main(string[] args) { try { try { throw new Exception("Test"); //Line 12 } ...
Floyd's user avatar
  • 1,928
3 votes
1 answer
327 views

Please find the code in the image below. 1. Assign the returned value of a function, which throws an error actually, to the variable 'withLet' that declared by using keyword 'let'. 2. call 'withLet', ...
Heyi's user avatar
  • 67
51 votes
3 answers
26k views

Just as I can see in cppreference, the classic "throw" declaration lists is now deprecated in C++11. What is the reason of leaving this mechanism and how should I have to specify what exceptions ...
ABu's user avatar
  • 12.6k
38 votes
1 answer
18k views

If in my code I have the following snippet: try { doSomething(); } catch (...) { doSomethingElse(); throw; } Will the throw rethrow the specific exception caught by the default ellipsis handler?...
WilliamKF's user avatar
  • 43.7k
34 votes
3 answers
1k views

Why do the following lines of code not create a compiler warning? void Main() { throw new Exception(); throw new Exception(); } As I see it, the compiler should inform you that the second throw ...
DaveShaw's user avatar
  • 53k

15 30 50 per page
1
2 3 4 5
8