exception

C++: If an exception is thrown, are objects that go out of scope destroyed?

空扰寡人 提交于 2019-12-30 21:21:53
问题 Normally it would be destructed upon the scope ending.. I could see issues occurring if exceptions were thrown though. 回答1: Yes. C++ Standard n3337 15 Exception handling § 15.2 Constructors and destructors 1) As control passes from a throw-expression to a handler, destructors are invoked for all automatic objects constructed since the try block was entered . The automatic objects are destroyed in the reverse order of the completion of their construction. 2) An object of any storage duration

H2 Java Insert ignore - allow exception

試著忘記壹切 提交于 2019-12-30 18:52:12
问题 I am working on a java plugin interfacing with an H2 database. What I really want is an "Insert Ignore" statement; however, I'm aware that H2 doesn't support this. I am also aware of Merge, but this is really not what I want, if the record exists I don't want to change it. What I am considering is to just run the insert and let the duplicate key exception happen. However, I don't want this to fill my log file. The DB call happens in an imported class that I can't change. So my questions are:

Without using recursion how can a stack overflow exception be thrown?

故事扮演 提交于 2019-12-30 18:33:08
问题 Without using recursion how can a stack overflow exception be thrown? 回答1: If you call enough methods, a stack overflow can occur anytime. Although, if you get stack overflow errors without using recursion, you may want to rethink how you're doing things. It's just so easy with recursion because in an infinite loop, you call a ton of methods. 回答2: Since no one else has mentioned it: throw new System.StackOverflowException(); You might do this when testing or doing fault-injection. 回答3:

Why are the names of generic types mangled in a .NET stack trace?

Deadly 提交于 2019-12-30 18:26:13
问题 I have an exception being thrown from a C# method, that takes a generic list as a paremeter. private static void DoWork(List<ClassName> a) { } When it throws an exception, the stack trace shows an `1 instead of the class name for the list. Why is this? This is what the stack trace has. ... at DoWork(List`1 a). ... 回答1: The reason why is that the stack trace is generated by the CLR and not C#. Hence it uses CLR type names vs. C# type names. The type names given to generic types in metadata (in

PDO “Uncaught exception 'PDOException' .. Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll().”

一世执手 提交于 2019-12-30 18:09:23
问题 I know this question has been asked many times, but I've read the answers to many of the questions and still cannot understand why I am receiving this error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE

What's a “recursive_init_error” exception?

好久不见. 提交于 2019-12-30 17:43:47
问题 I decided to do a test with computed gotos and local statics void g() { std::cout << "init "; } void f() { int z = 0; y: z++; static int x = (g(), z == 1 ? ({ goto *&&y; 0; }) : 0); } int main() { f(); std::cout << "!"; f(); } I wanted to see whether the output would be "init init !". But to my surprise I didn't get that output, but instead GCC handled it gracefully, outputting at runtime: init terminated by recursive_init_error: exception What's that exception? Is it a Standard exception? C+

why does n.GetHashCode() work but n.GetType() throws and exception?

妖精的绣舞 提交于 2019-12-30 17:28:28
问题 I am teaching myself C# (I don't know much yet). In this simple example: bool? n = null; Console.WriteLine("n = {0}", n); Console.WriteLine("n.ToString() = {0}", n.ToString()); Console.WriteLine("n.GetHashCode() = {0}", n.GetHashCode()); // this next statement causes a run time exception Console.WriteLine("n.GetType() = {0}", n.GetType()); Intuitively I understand why the GetType() method would throw an exception. The instance n is null which would explain that but, why don't I get an

Prevent Visual Studio from breaking on unhandled exceptions

三世轮回 提交于 2019-12-30 17:27:10
问题 I have a set of NUnit tests (running using the Resharper test runner), and some of those fail due to assertion exceptions happening in background threads; and when this happens VS2017 breaks into the debugger, what is undesirable as I want it to keep on running other tests. All the settings in "Exception Settings/CLR/Thrown" are turned off. The "User-Unhandled" settings in that dialog aren't present whether I switch the "Just My Code" option on or off All the "Exception Settings/Managed

No exception of type DataAccessException can be thrown; an exception type must be a subclass of Throwable

人盡茶涼 提交于 2019-12-30 17:21:32
问题 My source code like below. It has a error, "No exception of type DataAccessException can be thrown; an exception type must be a subclass of Throwable". I can't understand why the error ocurrs. let me know. thx. package com.sds.afi.cosmos.cmm.db.impl; import java.sql.SQLException; import java.util.HashMap; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.orm.ibatis

Exception when taking a heapdump using JMAP

蓝咒 提交于 2019-12-30 16:25:38
问题 I get the following exception when i take a heapdump using jmap -F -dump:format=b,file=/tmp/heapdump/before.hprof 10737 Attaching to process ID 10737, please wait... Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method