throw Questions

6

Solved

I'm writing a custom class in C# and I'm throwing a couple exceptions if people give the wrong inputs in some of the methods. If the exception is thrown, will any of the code in the method after th...
Physicalism asked 13/6, 2009 at 6:20

3

Solved

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 th...
Outrider asked 12/12, 2012 at 14:7

2

Solved

I was reading the book Professional Javascript For Web Developers, and saw the following code. I have some questions about it: What does "throw new Error()" return? Undefined? What will happen ...
Cyclothymia asked 21/2, 2017 at 21:10

1

Solved

#include <iostream> using namespace std; constexpr int f(bool b){ return b ? throw 0 : 0; } // OK constexpr int f() { return f(true); } // Ill-Formed, No Diagnostic Required int main(){ ...
Dispirit asked 31/1, 2017 at 15:21

3

Solved

I am interested to know best practice to use throw new Exception() and new Exception(). In case of using new Exception(), I have seen that code moves to next statement instead of throwing exception...
Ex asked 23/10, 2016 at 7:38

5

Solved

For the code below, result is "EA Exception Finished", which means although we threw at derived class it caught by base class. Is it always? And if so, how can I make the derived class catches, thu...
Giltzow asked 16/9, 2016 at 9:25

1

I know that stackoverflow is full of similar question and I've read a lot of them. From what I got a throw inside a promise should reject it, as I can read in the documentation: If the e...
Perceptual asked 31/8, 2016 at 9:15

2

Solved

Could someone explain to me why this code doesn't compile with g++ version 6.2.0, but compiles fine with clang++ version 3.9.0-svn274438-1 and icpc version 16.0.2 $ cat wtf.cpp #include <cstdio...
Fettle asked 28/8, 2016 at 7:23

1

I am new to C++, so sorry for asking very silly questions but I am confused with the throw statements in Exception Handling mechanism of C++. In the below code why do we call a function with name ...
Extract asked 9/8, 2016 at 11:25

12

Solved

I rethrow an exception with "throw;", but the stacktrace is incorrect: static void Main(string[] args) { try { try { throw new Exception("Test"); //Line 12 } catch (Exception ex) { throw; //...
Fission asked 18/11, 2010 at 17:15

2

Solved

In Chrome, when an exception occurs, it prints a stack trace to the console log. This is extremely useful, but unfortunately in cases where an exception has been rethrown this causes an issue. } c...
Approximate asked 9/3, 2011 at 17:47

1

I want to throw a custom exception which is the data validation exception in a controller of my CakePHP application. How do I create my own custom exception handler in Cakephp so that I can throw t...
Transitive asked 23/6, 2015 at 6:42

1

Solved

I get following error: Throwing method cannot be a member of an @objc protocol because it returns a value of type 'Bool'; return 'Void' or a type that bridges to an Objective-C class When defini...
Macrophage asked 8/3, 2016 at 14:34

3

Solved

Is it possible to throw a Lua error from a function to be handled by the script calling the function? For example the following will throw an error at indicated comment local function aSimpleFunc...
Distributive asked 1/3, 2016 at 23:44

3

Solved

From C++ Primer 18.1.1: If the [thrown] expression has an array or function type, the expression is converted to its corresponding pointer type. How is it that this program can produce correc...
Henkel asked 13/1, 2016 at 13:26

2

Solved

I'm working on a swift project that need to interact with an existing objective-c api. I've run into a bit of a roadblock with one of the functions though. In the objective-c header file (OrderItem...
Infraction asked 9/12, 2015 at 19:17

6

Solved

Under which circumstances are the following two codes not equivalent? { // some code, may throw and/or have side effects } try { // same code as above } catch(...) { throw; } edit Just to ...
Josie asked 13/11, 2015 at 9:3

2

Solved

Assume the following class: class Example { public: ... Example& operator=(const Example& rhs); ... private: other_type *m_content; size_t m_content_size; } Example& Example::opera...
Vermis asked 9/11, 2015 at 13:36

1

Solved

Consider the fragment: try { Foo f; throw std::move(f); } catch (Foo& f) { } [expr.throw] says that: the type of the exception object is determined by removing any top-level cv-qualifi...
Paleontology asked 24/9, 2015 at 12:18

2

Solved

I'm using this code inside the public function __construct() of a class: $this->mConnection = mysql_connect(BASE_DB_HOST,BASE_DB_USER,BASE_DB_PASS) or throw new Exception("Couldn't connect to d...
Portugal asked 1/2, 2013 at 6:26

3

Solved

Doing a code analysis gave me item CA2200: CA2200 Rethrow to preserve stack details 'func()' rethrows a caught exception and specifies it explicitly as an argument. Use 'throw' without an argume...
Townspeople asked 22/11, 2013 at 15:0

1

Solved

When should I use Exception, InvalidArgumentException or UnexpectedValueException? I don't know the real different between them as I always used Exception.
Infallible asked 6/7, 2015 at 20:57

4

Solved

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 "...
Piping asked 31/7, 2009 at 14:50

3

Solved

I am adding some validation to a couple of stored procedures and need to check if some of the variables are not null (they are populated earlier in the stored procedure). I have been trying to add...
Diabolism asked 5/8, 2013 at 8:0

5

Solved

I know that I shouldn't throw exceptions from a destructor. If my destructor calls a function that can throw an exception, is it OK if I catch it in the destructor and don't throw it further? Or ...
Tarr asked 27/7, 2009 at 13:47

© 2022 - 2024 — McMap. All rights reserved.