Is there a way to determine if an exception is occurring?
In a destructor, is there a way to determine if an exception is currently being processed? ...
In a destructor, is there a way to determine if an exception is currently being processed? ...
Here's a question to expose my lack of experience: I have a method DoSomething() which throws an exception if it doesn't manage to do it cleanly. If it fails, I try the less accurate method DoSomethingApproximately() several times in the hope that it will find a sufficiently good solution; if this also fails I finally call DoSomethingIna...
I'm using VS2008 to debug an application that starts a new process. I believe that the spawned process is suffering (and handling) some kind of CLR exception during its start-up, but it is not being caught by turning on CLR Exception Notification in Debug -> Exceptions. Any suggestions on how I can see where the exception is generated? I...
If I have a subclass that has yet to implement a function provided by the base class, I can override that function and have it throw a NotSupportedException. Is there a way to generate a compile-time error for this to avoid only hitting this at runtime? Update: I can't make the base class abstract. ...
I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains no asserts whatsoever and my question is this... Should I begin using Asserts in our pr...
Sometimes I find myself in the situation where I want to execute several sequential commands like such: try: foo(a, b) except Exception, e: baz(e) try: bar(c, d) except Exception, e: baz(e) ... This same pattern occurs when exceptions simply need to be ignored. This feels redundant and the excessive syntax causes it t...
How does one write a test that fails only if a function doesn't throw an expected exception? ...
Most people say never throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes the point that "the vector destructor explicitly invokes the destructor for every element. This implies that if an element destructor throws, the vector destruction fails... There is really no good way to protect agains...
In one of our application im getting an exception that i can not seem to find or trap. ... Application.CreateForm(TFrmMain, FrmMain); outputdebugstring(pansichar('Application Run')); //this is printed Application.Run; outputdebugstring(pansichar('Application Run After')); //this is printed end. <--- The Exception seems to b...
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse Is there a wa...
I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are: Use the file-per-class rule. I'm not crazy about this because it either clutters up my directory structure and namespaces. I could organize them into subdirectories and segment namespaces for ...
I am trying to copy a file using the following code: File targetFile = new File(targetPath + File.separator + filename); ... targetFile.createNewFile(); fileInputStream = new FileInputStream(fileToCopy); fileOutputStream = new FileOutputStream(targetFile); byte[] buffer = new byte[64*1024]; int i = 0; while((i = fileInputStream.read(buf...
We have consumed a third party web service and are trying to invoke it from an ASP.NET web application. However when I instantiate the web service the following System.InvalidOperationException exception is thrown: Method 'ABC.XYZ' can not be reflected. System.InvalidOperationException: Method 'ABC.XYZ' can not be reflected. -...
I have a basic C# console application that reads a text file (CSV format) line by line and puts the data into a HashTable. The first CSV item in the line is the key (id num) and the rest of the line is the value. However I've discovered that my import file has a few duplicate keys that it shouldn't have. When I try to import the file the...
Hello, I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a std::string pointer? Here's what I was looking forward to doing: void Foo::Bar(){ if(!QueryPerformanceTimer(&m_baz)){ throw new std::String("it's the end of the world!"); } } void Foo:Caller(){ try{...
short: Is there a way in Ruby to DRY-ify this: def entry_point_one begin do_something rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => syn_err raise syn_err.exception(syn_err.message) end end def entry_point_two begin do_something_else rescue MySyntaxErrorOne, MySyntaxErrorTwo, MySyntaxErrorEtc => s...
The questions says everything, take this example code: <ul id="css-id"> <li> <something:CustomControl ID="SomeThingElse" runat="server" /> <something:OtherCustomControl runat="server" /> </li> </ul> Now if an error gets thrown somewhere inside these controlls (that are located in a master page) they will take down the...
What is the cause of this exception in ASP.NET? Obviously it is a viewstate exception, but I can't reproduce the error on the page that is throwing the exception (a simple two TextBox form with a button and navigation links). FWIW, I'm not running a web farm. Exception Error Message: Unable to validate data. Error Source: S...
This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below? try { // Do something } catch(IOException e) { throw new Application...
I know most people think that as a bad practice but when you are trying to make your class public interface only work with references, keeping pointers inside and only when necessary, I think there is no way to return something telling that the value you are looking doesn't exist in the container. class list { public: value...