exception-handling

Common programming mistakes in .Net when handling exceptions?

What are some of the most common mistakes you've seen made when handling exceptions? It seems like exception handling can be one of the hardest things to learn how to do "right" in .Net. Especially considering the currently #1 ranked answer to Common programming mistakes for .NET developers to avoid? is related to exception handling. ...

Proper exceptions to use for nulls

In the following example we have two different exceptions we want to communicate. //constructor public Main(string arg){ if(arg==null) throw new ArgumentNullException("arg"); Thing foo=GetFoo(arg); if(foo==null) throw new NullReferenceException("foo is null"); } Is this the proper approach for both exception ty...

SWIG: Throwing exceptions from Python to C++

We've got an interface we've defined in C++ (abstract class, all functions pure virtual) which will be extended in Python. To overcome the cross-language polymorphism issues we're planning on using SWIG directors. I've read how to catch exceptions thrown from C++ code in our Python code here, here, here, and even on SO. It's fairly st...

Java Terminology: Why compile-time error and not compile-time exception?

This may sound awkward ... But I didn't understand it. Why do we have compile-time error and not compile-time exception in java ? I mean to say that we never say compile-time exception. We tend to say it as compile-time error. Is there any specific reason for the same ?? Any suggestions are welcomed.... Thanks ! ...

Global Error Handling for Web Services

I have a web project consisting of only web services. I need a global way of handling errors on the server so I can send emails, log in event log, etc. Global.asax doesn't work according to MSDN. How should I go about this? I have tried creating a soapExtension, but it is never hit. ...

why is java.lang.Throwable a class?

In java adjectives ending in -able are interfaces Serializable, Comparable etc... So why is Throwable a class? Wouldn't exception handling be easier if Throwable were an interface? (Edit: e.g. Exception classes don't need to extend Exception/RuntimeException.) Obviously, changing it now is out the question. But could it be made abstract...

.Net: Do you know a complete downloadable Exception Handling tutorial or Resource ?

hi Do you know a complete Exception Handling tutorial which just focuses on it and talks about it in detail? EDIT: I prefer download-able resource. ...

How can I make exception handling for all existing SQL server 2005 Stored Procedures, view and functions ?

we have a portal that have SQL server 2005 database that contain about 1750 stored procedures , 250 view and 200 function and 95% of them not have handling exception in their code .. we search about any way that allow us making such a global exception handling in SQL that receive any exception happen in any SP,view or function and stored...

What is the difference between C++, Java and JavaScript exception handling?

They are very different kind of languages and the way they handle exceptions might be rather different.. How is exception handling implemented and what are the implementation difference within these languages? I am asking this question also because I noticed that C++ exception handling seems to be very slow compared to the JavaScript ve...

Exceptions by DataContext

I've been doing some searching on the internet, but I can't seem to find the awnser. What exceptions can a DataContext throw? Or to be more specific, what exceptions does the DataContext.SubmitChanges() method throw? EDIT For reference, here a List of possible known exceptions that could be thrown by the L2S DataContext: SqlException ...

Exceptions and Access Violations in Paint events in Windows

After executing some new code, my C++ application started to behave strange (incorrect or incomplete screen updates, sometimes no screen updates at all). After a while we found out that the new code is causing an Access Violation. Strange enough, the application simply keeps on running (but with the incorrect screen updates). At first ...

Need to determine if ELMAH is logging an unhandled exception or one raised by ErrorSignal.Raise()

I am using the Elmah Logged event in my Global.asax file to transfer users to a feedback form when an unhandled exception occurs. Sometimes I log other handled exceptions. For example: ErrorSignal.FromCurrentContext().Raise(new System.ApplicationException("Program code not found: " + Student.MostRecentApplication.ProgramCode)); // mo...

How can I tell Visual Studio to NOT BREAK on a particular exception?

I have a particular type of exception that I would like Visual Studio to not break on and show the Exception Assistant screen. Essentially I would like it just to let my normal exception handling infrastructure deal with it. The exception is an inheritor of System.Exception which I wrote and have the source code for. Any where this is...

How to handle server sided exceptions with AJax queries on the client end?

Hi guys I've noticed that at times exceptions do get thrown on server sided code - however when it comes to ajax requests how do I implement it such that I'm able to inform the user that an exception has been thrown and something has gone wrong? I'm using Php on the back end here. ...

How to handle error on other thread?

Hi, I'm trying to handle errors that have occurred on other threads the .NET CF program is like below: static void Main() { Thread t = new Thread(Start); t.Start(); ... } void Start() { ... Exception here } In my situation, putting try catch in the Start method is impossible. How can I handle it in the global code?...

Is there any good best practices for exception handling in rails?

I'm currently on Rails 2.3.5 and I'm trying rescue_from exceptions as neat as possible in my Application. My ApplicationController rescues look like this now: rescue_from Acl9::AccessDenied, :with => :access_denied rescue_from Exceptions::NotPartOfGroup, :with => :not_part_of_group rescue_from Exceptions::SomethingWentWrong, :wit...

How should I re-raise a Delphi exception after logging it?

Do you know a way to trap, log, and re-raise exception in Delphi code? A simple example: procedure TForm3.Button1Click(Sender: TObject); begin try raise Exception.Create('Bum'); except on E: Exception do begin MyHandleException(E); end; end; end; procedure TForm3.MyHandleException(AException: Exception); beg...

[PHP] Difference between exceptions and errors?

What is the difference between an error and an exception? I have read numerous resources online and in a couple of books, but the explanations provided are not very thorough. As such, I am still confused. Thanks! Edit: It looks like I asked two questions which was probably confusing. The main question that I wanted an answer to is th...

Logging exceptions to database in NServiceBus

If an exception occurs in my MessageHandler I want to write the exception details to my database. How do I do this? Obviously, I cant just catch the exception, write to database, and rethrow it since NSB rollbacks all changes. (IsTransactional is set to true) I tried adding logging functionality in a seperate handler, which I caledl us...

Catch Exception only in release

HI, I have one global generic exception handler(catch ex as Exception) for all unhandled exceptions from application. But in debug mode(app runs from VS) I don`t want that exceptions go to this global handler. Better for me is when VS stops app on place when exception occurs. How can I do this, or is there some better approach for this?...