exception-handling

Behaviour of exception handling in constructor of a class

一笑奈何 提交于 2019-12-24 02:26:07
问题 I have this program where the ctor of derived class throws a exception. The program is just an example program where I am just trying to understand the concept of exception handling. class A{ public: A() {} ~A(){std::cout << "DTOR called - A!!" << std::endl;} }; class B : public A { public: B():A() { try { init(); } catch(...) { std::cout << "Inside catch block in B's Ctor!!" << std::endl; throw this; } } void init() { throw 0; } ~B() {std::cout << "DTOR called - B!!" << std::endl; } }; int

Exception thrown by a thread in a third party library

对着背影说爱祢 提交于 2019-12-24 02:22:59
问题 I am using a third party library in my code. One of the methods on the third party library is getting a thread from the thread pool and doing some work on it. Unfortunately it is throwing an exception from its thread which I am unable to catch and handle because it is from a different thread. I know that this exception is not going to cause the application any harm (it is not an out of memory exception or anything similar), so I'd like to log it and try the operation again later when it might

Handling exceptions in a class library enveloping a device driver

…衆ロ難τιáo~ 提交于 2019-12-24 01:55:42
问题 I am writing a class library that envelopes an USB device driver. This device has its own class library, provided by the hardware vendor. Very often, especially if you handle with old DLL or COM assemblies, there are methods (functions to be correct) that return TRUE if all was OK, or FALSE if any error happen. Often these methods return information about the error in one of their parameters or separately in a GetLastError method or even if in an OnError event. Now, normally I handle all

Cant get info from FaultExceptions (javascript)

◇◆丶佛笑我妖孽 提交于 2019-12-24 01:48:44
问题 Until now I have used an webservice ASMX which I call from javascript. It has been working fine, but because I needed some control over the serialization, I am trying to switch to DataContracts and WCF. However, I do believe that there is something I have misunderstood, because Im trying to catch faultexceptions from the client code (javascript), but the only errorcode Im receiving is: (translated, so might not be accurate) "The server could not handle the request because of an intern error.

Catch every exception of program?

你说的曾经没有我的故事 提交于 2019-12-24 01:27:15
问题 I've a WPF application which runs globally fine. But sometimes, the client tell me that he gots some crashes. But I've no information about what happened except what he does. Is there a way to put a global try{}catch(Exception){LOGEXCEPTION; throw;} somewhere to receive all exceptions generated by a GUI action, or any other option. Something like a "Last remedy" to log exception that we didn't manage well? Thank you! 回答1: By handling the following events, you should be able to catch the vast

gfortran warn on floating point exception

▼魔方 西西 提交于 2019-12-24 01:00:53
问题 I'm using gfortran for some code. For a while now, I've been compiling with -ffpe-trap=zero,overflow,invalid in an attempt to hunt down some bugs. This causes my program to cease execution immediately. There are some cases where the FPE might be OK and so a flag like: -ffpe-warn=zero,overflow,invalid would be very useful. Does gfortran (or any other compiler) provide anything like this? If not, are there any workarounds? My current thought is to create a C function to register a signal

Why is boost::filesystem aborting instead of throwing an exception?

帅比萌擦擦* 提交于 2019-12-24 00:53:49
问题 I'm migrating some code from VS2010 (using boost 1.55) to VS 2015 (using boost 1.60). I end up with "Microsoft Visual C++ Runtime Library" reporting that abort() has been called while boost rties to throw an exception. However, I could get it throw other exceptions without any problem (and it used to work with VS2010/boost1.55): #include <boost/filesystem.hpp> #include <boost/filesystem/operations.hpp> #include <iostream> int main( int argc, char* argv[] ) { // Stepping to folder: try { boost

Throw exception in Java

放肆的年华 提交于 2019-12-24 00:52:12
问题 Suppose I have a class, the requirement is that "change the following code to throw checked exception if "den" is 0, and change the function to catch that exception". public class divide { void divide(int num, int den){ System.out.println(""+(num/den)); } void fun(){ divide(4,2); } } Which of the following one is the correct way to throw exception? Option 1: void divide(int num, int den) throws Exception{ if(den==0){ throw new Exception("Dividebyzero"); } System.out.println(""+(num/den)); }

Parse error while installing downloaded .apk file

安稳与你 提交于 2019-12-24 00:45:47
问题 Hi after Two weeks again i started my research and struggling with this Error * Parse Error: *There is a problem parsing package. Scope of my implementation is am trying to update my app from a server where i have the updated apk file and am downloading it through my app using service .Now am at edge of the Stage i can download the file from that server an i can able to install it by manually.But my scope is like after file is downloade from the Server it should automatically invoke the

Catching exception and throwing the same?

℡╲_俬逩灬. 提交于 2019-12-24 00:35:46
问题 Could you please tell me which approach is better in below two code blocks? catch (MyException e) { throw new MyException ("Error processing request", e); } Or catch (MyException e) { throw e; } 回答1: In order to compare two approaches, they should do the same thing. These two do not do the same thing . The first approach would be better because you would change its message to a more user friendly one. Perhaps you could also log it (stacktrace or whatever...) before rethrowing it. The second