exception

Exceptions in constructors

In C++, the lifetime of an object begins when the constructor finishes successfully. Inside the constructor, the object does not exist yet. Q: What does emitting an exception from a constructor mean? A: It means that construction has failed, the object never existed, its lifetime never began. [source] My question is: Does the ...

How to retrieve brand and model info by code on Android ?

There is an class android.os.Build that got static variables cointaining device info, but when i try to access it I allways get a runtime exception. E.x on how I try to access it: String model = Build.MODEL; I always get an Exception like this: 04-14 14:57:45.266: ERROR/AndroidRuntime(770): java.lang.VerifyError: com.mypackage.Main ...

What exception type to throw for unrecognized ID paramater?

ITool GetTool(Guid tool) { if (tool == Hammer.Id) return new Hammer(); else if (tool == Drill.Id) return new Drill(); else throw new ....? } What's the most appropriate exception type to throw here? NotSupportedException is the closest I've found but I don't think that's quite right. ...

Getting meaningful error messages from fstream's in C++

What is the best way to get meaningful file access error messages, in a portable way from std::fstreams ? The primitiveness of badbits and failbits is getting to be bit annoying. I have written my own exception hierarchies against win32 and POSIX before, and that was far more flexible than the way the STL does it. I am getting "basic::i...

How do I make VC++'s debugger break on exceptions?

I'm trying to debug a problem in a DLL written in C that keeps causing access violations. I'm using Visual C++ 2008, but the code is straight C. I'm used to Delphi, where if an exception occurs while running under the debugger, the program will immediately break to the debugger and it will give you a chance to examine the program state...

Throwing a C++ exception after an inline-asm jump

I have some odd self modifying code, but at the root of it is a pretty simple problem: I want to be able to execute a jmp (or a call) and then from that arbitrary point throw an exception and have it caught by the try/catch block that contained the jmp/call. But when I do this (in gcc 4.4.1 x86_64) the exception results in a terminate...

WCF Webservices and FaultContract - Client's receiving SoapExc insted of FaultException<TDetails>

Hi All, i'm developing a WCF Webservice and consuming it within a mvc2 application. My problem is that i'm using FaultContracts on my methods with a custom FaultDetail and i'm throwing manyally the faultexception but when the client receive the exception , it receives a normal SoapException instead of my FaultException that i throwed fr...

RuntimeBinderException with dynamic in C# 4.0

I have an interface: public abstract class Authorizer<T> where T : RequiresAuthorization { public AuthorizationStatus Authorize(T record) { // Perform authorization specific stuff // and then hand off to an abstract method to handle T-specific stuff // that should happen when authorization is successful ...

how to debug ExceptionInInitializationError?

I am getting an exception in a very simple 'study' application, so I expect the problem to be in my project setup, but I don't know how to debug ... What is the context of the exception, "ExceptionInInitializationError"? Where is it documented? A: Search Android Developers Guide Stack trace from within Eclipse Debugger with: select t...

How can I call VC# webservice methods without ArgumentException?

Currently, I'm trying to write a small tray application that will show the status and provide control of a server-side application exposed over webservice. The webservice only has 3 operations: start, stop and status. When I call any of these operations in code, they throw an ArgumentException citing "An item with the same key has alread...

What sort of exceptions should I be throwing from inside Kohana 3?

I've seen the code examples on this article, but throwing Controller_Exception_404 produces an error. I've just been throwing plain exceptions. I remember in Kohana 2.3 there were different ones you could throw, depending on the situation. Does anyone have a list of what exceptions should be thrown when? ...

ExecutionEngineException thrown when loading native dll

I have a 32-bit .net application that uses a native 32-bit DLL via DllImport(). The native DLL is our internal file analysis library, and I need to use it as porting it to C# would be a problem if people update it (other software uses it). The problem is that when I try to execute any method in the native DLL I get a System.ExecutionEng...

ASP.NET "Object reference not set..." error

Hi, I have a website written using ASP.NET. We have a development machine and a deployment server. The site works great on the development machine, but when is transfered (using simple FTP Upload) generates strange behavior. It starts working just fine, but after a while stops working and throws an exception "Exception: Object reference ...

asp.net Background Threads Exception Handling

In my 3.5 .net web application I have a background thread that does a lot of work (the application is similar to mint.com in that it does a lot of account aggregation on background threads). I do extensive exception handling within the thread performing the aggregation but there's always the chance an unhandled exception will be thrown a...

Unable to validate data. at System.Web.Configuration.MachineKeySection.GetDecodedData

I have several websites which get approximately 3000 pageviews in total per day, and I get this viewstate error roughly 5-10 times per day, caught in global.asax: System.Web.HttpException: Unable to validate data. at System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& ...

Scala: Can't catch exception thrown inside a closure

Disclaimer: absolute novice in Scala :( I have the following defined: def tryAndReport(body: Unit) : Unit = { try { body } catch { case e: MySpecificException => doSomethingUseful } } I call it like this: tryAndReport{ someCodeThatThrowsMySpecificException() } While the call to someCodeThatThrowsMySpecificException...

C++ catch constructor exception

hi. I do not seem to understand how to catch constructor exception. Here is relevant code: struct Thread { rysq::cuda::Fock fock_; template<class iterator> Thread(const rysq::cuda::Centers &centers, const iterator (&blocks)[4]) : fock_() { ...

Alternative to rescue in Ruby?

It seems like I have begin ... rescue ... end statements everywhere in my code! This doesn't seem like the correct thing to do. Can anyone suggest how I can catch any exceptions without having to place everything inside begin ... rescue ... end? Any way to just tell Ruby to shut up and just keep going even if an exception is raised? ...

Why is TargetInvocationException treated as uncaught by the IDE?

I have some code that is using reflection to pull property values from an object. In some cases the properties may throw exceptions, because they have null references etc. object result; try { result = propertyInfo.GetValue(target, null); ...

When is a try catch not a try catch?

I have a fun issue where during application shutdown, try / catch blocks are being seemingly ignored in the stack. I don't have a working test project (yet due to deadline, otherwise I'd totally try to repro this), but consider the following code snippet. class IndexNotFoundException : Exception { } public static string RunAndPossibly...