Skip to main content
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
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
119 votes
4 answers
6k views

I picked this up in one of my brief forays to reddit: http://www.smallshire.org.uk/sufficientlysmall/2009/07/31/in-c-throw-is-an-expression/ Basically, the author points out that in C++: throw "...
user avatar
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
104 votes
7 answers
141k views

I am facing the famous 'Incorrect syntax' while using a THROW statement in a T-SQL stored procedure. I have Googled it and checked the questions on StackOverflow but the solutions proposed (and ...
user3021830's user avatar
  • 2,964
95 votes
3 answers
73k views

Possible Duplicate: how to use Java-style throws keyword in C#? i have a function where an exception occurs say for example private void functionName() throws Exception { // some code that ...
user avatar
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
73 votes
6 answers
50k views

At the moment I'm extending my JavaScript project with error handling. The throw statement is playing an important role here: throw new Error("text"); // Error: text However, can I also throw a ...
pimvdb's user avatar
  • 155k
70 votes
5 answers
16k views

PEP 342 (Coroutines via Enhanced Generators) added a throw() method to generator objects, which allows the caller to raise an exception inside the generator (as if it was thrown by the yield ...
NikiC's user avatar
  • 102k
67 votes
3 answers
104k views

I'm learning to use python. I just came across this article: http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html It describes rethrowing exceptions in python, like this: try: ...
Bosiwow's user avatar
  • 2,263
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
62 votes
3 answers
9k views

Conventional wisdom says you can only throw objects that extend Throwable in Java, but is it possible to disable the bytecode verifier and get Java to compile and run code that throws arbitrary ...
NullUserException's user avatar

15 30 50 per page
1
2 3 4 5
61