exception

Exception elimination in C++ constructors

We have recently been faced with the problem of porting our C++ framework to an ARM platform running uClinux where the only vendor supported compiler is GCC 2.95.3. The problem we have run into is that exceptions are extremely unreliable causing everything from not being caught at all to being caught by an unrelated thread(!). This seems...

Print Stack Trace to Screen in J2ME

Is there a way to print a stack trace to screen in j2me? I have code that looks like the following, which works fine for displaying the message, but can't figure out any way to get ahold of the stack trace. try { throw new RuntimeException("This is bad stuff!"); } catch (Exception e ) { mainForm.append("Excep...

What's the best way to raise an exception in C#?

I traditionally deploy a set of web pages which allow for manual validation of core application functionality. One example is LoggerTest.aspx which generates and logs a test exception. I've always chosen to raise a DivideByZeroException using an approach similar to the following code snippet: try { int zero = 0; int result = 100 ...

Image.Save(..) throws a GDI+ exception because the memory stream is closed.

Hi folks, i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream. this is the code: [TestMetho...

Rolling my own exceptions

I am writing some new code that will throw a custom exception - I want to include an error string and a status code. Which class should be exception derive from? std::exception? std::runtime_error? Any other 'gotchas' to worry about? I'm thinking of something like the following: class MyException : public std::exception(?) { public:...

Why catch an exception just to throw it again?

In an webservice I see this code: Whats the point of catch the exception and just throw it again? Do I miss something? <WebMethod()> _ Public Function dosomething() As Boolean Try If successful Then Return True Else Return False End If Catch ex As Exception Throw ex End...

When to rethrow an exception, when to return FALSE?

I am developing a wrapper for a third party function library that is interfacing with some special hardware. So basically, I want to encapsulate the dll functions (bool Connect(), void Disconnect() etc) in a MyHardwareObject with connect- and disconnect methods. The Connect function from the dll can throw some specific exceptions, for e...

C# - How to implement one catch'em all exception handler with resume?

Hi Guys, i wonder how can i write a catch'em all exception handler in the application level which will give the user the option to resume the application flow? Thanks!!! ...

Does Javascript fire an event for unhandled/uncaught exceptions?

I'm looking to log unhandled javascript exceptions. Is there an event that fires when an exception isn't caught? I'm looking to catch the exceptions before they cause javascript errors in the browser, but I'd rather not run my entire application inside of a try/catch. Any help would be appreciated. Thanks! Update: tvanfosson pointed ou...

Why do I keep getting a NullPointerException in the Java BasicTableUI$Handler.setValueIsAdjusting?

I keep getting this NPE in my application and I can't seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here? 11:28:23,273 [AWT-EventQueue-0] ERROR...

How do I fix a .NET Webservice timeout causing a UnsupportedMediaException in a Java client?

I currently have a .net SOAP web service with a timeout on the request that I set using Server.ScriptTimeout = TIME_OUT; I then have java client calling said web service. However when the timeout is reached I get this exception: Exception in thread "Thread-9" com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: ...

Using only std::exception in exception specification

It seems it is general accepted that exception specifications are not helping as much as one thinks. But I wonder if a specification which only uses std::exception might be a good compromise: void someFunction() throw ( std::exception ); It documents the fact that this method/function might throw an exception. It would make sure ...

Are all .NET exceptions serializable?

Can all .NET exception objects be serialized? Summary of responses: They should be, but historically, there have been exceptions. Objects in the Data dictionary may prevent the exception from serializing. ...

ASP.NET custom error page - Server.GetLastError() is null

I have a custom error page set up for my application: <customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx" /> In Global.asax, Application_Error(), the following code works to get the exception details: Exception ex = Server.GetLastError(); if (ex != null) { if (ex.GetBaseException() != null) ...

How to get which page threw an exception to Application_error in aspx

I have a general exception handler, Application_error in my global.asx what I'm trying to isolate all the uncaught exceptions on all my many pages. I don't want to use Page_error to catch exception because it's inefficient to call that on so many pages. So where in the exception can I find what page actually caused the exception. anythi...

How Can I Avoid Using Exceptions for Flow Control?

I have been assigned a project to develop a set of classes that act as an interface to a storage system. A requirement is that the class support a get method with the following signature: public CustomObject get(String key, Date ifModifiedSince) Basically the method is supposed to return the CustomObject associated with the key if an...

c# windows-services - How do I handle logging exceptions?

I am creating a Windows service. When an exception occurrs, I handle it appropriately and create a log. I am using the decorator pattern, as there are many different ways people will be looking at these logs. I have an email logger, a file logger, and a windows event logger, all which inherit from LoggingDecorator, which implements ILogg...

Why can't yield return appear inside a try block with a catch?

The following is okay: try { Console.WriteLine("Before"); yield return 1; Console.WriteLine("After"); } finally { Console.WriteLine("Done"); } The finally block runs when the whole thing has finished executing (IEnumerator<T> supports IDisposable to provide a way to ensure this even when the enumeration is abandoned ...

"Node cannot be inserted at the specified point in the hierarchy"

Hi, I am doing JavaScript Scaffold-like thing. And, code below is showing table. It works normal for all of them, and not for only one table I am getting - in the centring of processing on the third row - I get exception "Node cannot be inserted at the specified point in the hierarchy". function table_one_view(table) { $.getJ...

How can I configure log4j to not print the exception stacktrace ?

We use Log4j (and Commons Logging) to log our error messages. Now we want to set up an additional log appender that outputs fatal errors to syslog, but without the exceptionally long Java stacktraces (those will still be available in the full log file). How would one configure this (using log4j.xml)? Is there a filter available to ignor...