exception

Rethrowing from caught ...

If I throw an exception: throw Cat("Minoo"); Then I catch and rethrow with ... at some lower level in the call stack: catch(...) { throw; } Then at some other lower level in the call stack I try to catch with: catch(const Cat& c) { //Will it enter here, and if so will c be valid data? } catch(...) { } ...

wpf DoDragDrop IndexOutOfRangeException

I'm trying to implement drag and drop behaviour between a bunch of ListViews. I've found this solution that uses attached properties: http://www.beacosta.com/blog/?p=53 But whenever I try to perform a drag and drop, I get the following error message in the debug log: A first chance exception of type 'System.IndexOutOfRangeException...

Unhandled exceptions in BackgroundWorker

I have a small WinForms app that utilizes a BackgroundWorker object to perform a long-running operation. The background operation throws occasional exceptions, typically when somebody has a file open that is being recreated. Regardless of whether the code is run from the IDE or not .NET pops up an error dialog informing the user that a...

How can I handle an IOException which I know can never be thrown, in a safe and readable manner?

"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair." -Douglas Adams I have an class FileItems. FileItems constructor takes a file, and throws an exce...

NSException thrown loading a XIB file with a UITextView

I have a XIB file with a UITextView, which I'm associating with a UITextView* outlet in my controller: @interface MyController : UIViewController <UITextViewDelegate> { IBOutlet UITextView *textView; } @property (nonatomic, retain) IBOutlet UITextView *textView; I've aded the prototype in desperation, I've not implemented any o...

Bad idea to rethrow ex.InnerException?

Basically, my question is short and sweet: Is the following a bad idea (encapsulating and rethrowing ex.InnerException instead of ex) (There's a similar question here, but not quite... I want to reencapsulate the InnerException, so the stack trace is preserved without reflecting on internals) public abstract class RpcProvider { pub...

What's wrong when 'the requested operation cannot be performed on a file with a user-mapped section open?'

I'm developing an application that is reading and writing a lot (but synchronously, though) to a certain file on disk. However, how larger the file gets, the more often I get the following IOException: The requested operation cannot be performed on a file with a user-mapped section open. occuring from: at System.IO.__Error.Win...

Backgroundworker : exception during cancellation

I have a background worker wich can be cancelled. The normal flows interrupt itself when the CancelPending variable turns to true (responding to user interaction on UI wich call worker.CancelAsynch() ) , exceptions are thrown because if that (since normal flow is interrupted, lots of null ref exception are thrown) So when the worker r...

Catch, Handle, then Rethrow Exception?

I ran into an interesting dilemna today. I have a function that handles information and checks for duplicate values, then returns the next number that is not a duplicate. So, I have something like this: Public Function GetNextNonDuplicateNumber(NumberToCheck as Long) as Long //the non-duplicate the function will return Dim...

C#: Finding a Missing Dependency

I'm getting this error message whiile running a Webservice I'm working on. it builds, but this happens when I Invoke: File or assembly name (Redacted).Framework, or one of its dependencies, was not found The stack trace shows that between my code and the target of the exception, there are 3 referenced DLLs and 4 layers of System.Refl...

Isn't an unchecked exception that is caught in a try block a checked exception in Java?

I was told that in Java, unchecked exceptions can be caught in a try block, but if it's caught, isn't it called a checked exception? ...

Wrap exceptions by runtime exceptions with an annotation

Is there a way to annotate a method so all exceptions thrown are converted to runtime exception automagically? @MagicAnnotation // no throws clause! void foo() { throw new Exception("bar")' } ...

Eclipse - java.lang.ClassNotFoundException

Hi all, I have no idea what's wrong here, so you guys are my last chance: When trying to start my JUnit-Test out of Eclipse, I get a "ClassNotFoundException". When running "mvn test" from console - everything works fine. Also, there are no problems reported in Eclipse. My project structure is the following: parent project (pom-packa...

How to signify to the compiler that a function always throws?

When calling functions that always throw from a function returning a value, the compiler often warns that not all control paths return a value. Legitimately so. void AlwaysThrows() { throw "something"; } bool foo() { if (cond) AlwaysThrows(); else return true; // Warning C4715 here } Is there a way to tell the...

any way to get some information at least for catch(...)

Is there any way to get at least someinformation inside of here? ... catch(...) { std::cerr<<"Unhandled exception"<<std::endl; } I have this as a last resort around all my code. Would it be better to let it crash, because then I at least could get a crash report? ...

boost exceptions

Do all boost exceptions derive from std::exception? If not do they all derive from some base exception class? ...

Throw keyword in function's signature (C++)

Hello If function or class method throws an exception it is considered to be a good practice to signify this in function's signature. I.e. bool some_func() throw (myExc) { ... if (shit_happens) { throw myExc("shit happens"); } ... } My should we do this ? What are the advantages (or may be disadvantages) of su...

Creating a CroppedBitmap at runtime - won't load from resource

I'm trying to write code that will load an image from a resource, and then crop it. This code works when I do all, or part, of it in XAML. I want to switch from all-XAML to all-code, so I can reuse this more than one place, with different Uris. But when I try to do the same thing in code, I get a DirectoryNotFoundException, because sudd...

Determining which code line threw the exception

In dotNet a line throws an exception and is caught, how can I figure out which line in which file threw the exception? Seems relatively straightforward, but I can't figure it out... ...

Is there a way to make sure Dispose() is called on exception during deserialization of an IDisposable class?

in c#, i am deserializing an object of a type that implements IDisposable with the following statement (for illustration only). XmlSerializer s = new XmlSerializer(typeof(MyDisposable)) MyDisposable o = (MyDispoable)s.Deserialize(filepath); afaik, the serializer tries to construct the object using the default ctor and assigning all pu...