Skip to main content
2 votes
0 answers
156 views

I have a program that works as expected if compiled by GCC, but behaves weirdly after porting to Visual Studio. The program throws an exception from noexcept(false) destructor (I know that it is a bad ...
Fedor's user avatar
  • 25.7k
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
3 votes
1 answer
168 views

My program changed its behavior after updating Visual Studio to the latest version (2026). Simplifying it, I got the following minimal example, which contains a ternary operator with a throw in ...
Fedor's user avatar
  • 25.7k
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
45 votes
9 answers
87k views

How can throw an error with options or a status code and then catch them? From the syntax here, it seems we can through the error with additional info: new Error(message, options) So, can we throw ...
Run's user avatar
  • 57.7k
4 votes
1 answer
400 views

The problem Using static_assert to generate compile-time error is not always easy because it requires a constant expression as first argument. I found, on StackOverflow, several example where throw ...
Oersted's user avatar
  • 4,928
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
2 votes
1 answer
168 views

Example: int foo() { throw 0; } int bar() { foo(); } foo here doesn't get a warning, while bar gets the error "must return a value". More typically, bar would have some return statements ...
H.v.M.'s user avatar
  • 1,746
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
0 votes
1 answer
36 views

I have set the compile option requireReturnValues="Error". I tried to compile the following example code but it doesn't pass the option: METHOD PUBLIC LOGICAL checkValue(i_cValue AS CHAR): ...
W0lfw00ds's user avatar
  • 2,138
-3 votes
1 answer
89 views

Is this throw statement even reachable? It's not showing as unreachable by compiler. public static async Task<List<string>> GetSomething(int id) { using (DbContext context = new ...
Chris Hayes's user avatar
  • 4,035
0 votes
0 answers
247 views

I have multiple layers of nested stored procedures, each with a try...catch block within them. However, I want each of these nested stored procedures to be able to properly run their own transaction ...
Leah's user avatar
  • 355
45 votes
5 answers
76k views

I've been learning Angular 4 and everything was going smoothly until I tried to implement catch handling in a service. I'm trying to use "rxjs" catch and throw but I've got an undefined function error ...
nick gowdy's user avatar
  • 6,561
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
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

15 30 50 per page
1
2 3 4 5
61