exception-handling

Should exception messages that are targeted to the developer be localized?

I am referring to exception messages that show the developer is incorrectly using an API. For example incorrectly passing a null to method. So the type of exception that the developer will get the first time they have run their incorrect code. The type of exception message that should never get to be displayed to the user of a system. ...

Elmah not working with asp.net site

I've tried to use elmah with my asp.net site but whenever I try to go to http://localhost:port/elmah.axd I get resource not found exception. My web.config is given below. <?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="elmah"> <section name="security" requirePermission="false" ...

ASP.Net: Is it possible to skip databinding of an element if an error occurs?

Hey everyone, I use a lot of repeaters for different elements of our sites, and I've always wondered if there was a way to have the repeater skip an element if an exception occurs instead of having the whole page crash? In particular, I've inherited a system from another developer that using a similar design, however he didn't include ...

Why and how would you use Exceptions in this sample PHP code?

Hi, I've been wondering why would I use Exceptions in my PHP. Let's take a look at a simple example: class Worker { public function goToWork() { return $isInThatMood ? // Okay, I'll do it. true : // In your dreams... false; } } $worker = new Worker; if (!$worker->goToWork()) { if (date('l',time()) == 'Sunday') echo "F...

All About Exceptions: What to do and Where to log?

My question actually comes in two parts hence the ambiguous title. Part One As far as I'm aware, you should never swallow an exception. Not even logging it and forgetting about. In general cases, I try to solve an exception and retry the code - for example, let's say I get a FileNotFound exception. I prompt the user to check the file ...

Bad Practice to run code in constructor thats likely to fail?

Hello everyone, my question is rather a design question. In Python, if code in your "constructor" fails, the object ends up not being defined. Thus: someInstance = MyClass("test123") #lets say that constructor throws an exception someInstance.doSomething() # will fail, name someInstance not defined. I do have a situation though, wher...

ELMAH vs Enterprise Library Exception Handling Block

My team is currently in the process of building an ASP.NET MVC application, and we're trying to decide which of these frameworks to implement to deal with error handling and logging. What are the reasons for choosing one of these over the other? ...

What exactly will happen if I disable C++ exceptions in a project?

Visual C++ has a compiler setting "Enable C++ Exceptions" which can be set to "No". What exactly will happen if I set it this way? My code never explicitly throws or catches exceptions (and therefore the first thrown exception will terminate the program anyway) and doesn't rely on stack unwinding - should I expect any more undesired beha...

Is there an easy way to output a human readable object graph (specifically for an exception)

I have a unhandled exception handler (an oxymoron if ever there was one) but I'd like to get more information out of it. At the moment it logs the exception message, stack trace etc. and recursively does the same for any inner exceptions. However often the exception is a derived type of the exception class and therefore I do not know a...

How to log exceptions in release mode

Stack trace is not enabled when a .net assembly is deployed in release mode. So we cannot get the stack trace from an exception and log it in production environment. For knowing where an exception occurred in the production code and log it, we use a weird approach which I am not comfortable with but I cannot come up with a better soluti...

Usage of try/catch blocks in C++

In general, I tend to use try/catch for code which has multiple failure points for which the failures have a common handler. In my experience, this is typically code which qualifies input or context before performing some action or output after performing some action. I have received counsel from literature and colleagues to minimize...

Action-specific exception handler HTML in Rails

I've got a bunch of XHR actions in a controller, which return some HTML to insert into the page. If the response is an error, then it puts the output into a special error div. So far, nothing particularly interesting. However, this general process doesn't work for Rails' exception handling. If I raise an exception in my XHR actions, ...

Handle access violation exception in C++ Builder?

I'm trying to do: try{ int * i = NULL; *i = 3; }catch(Exception &Err){ ShowMessage(Err.Message); } I though that this should catch access violation exception and handle it by displaying an error message. But for some reason I get simple 'Access Violation' message instead of full one: 'Access Violation XXX in module YYY. W...

BizTalk scope "Catch Exception" General Exception message

I have a BizTalk (2006 R2) scope with a "Catch Exception" part in which I have put a simple Expression shape to store the exception message in an orchestration variable. The problem is that if I choose the exception type to be "General Exception" the I do not get to supply an exception object name. Where do I retrieve exception info in ...

Turn off customErrors for web service only

My ASP.NET 2.0 web app includes a web service, which throws various exceptions along with custom error messages (e.g. "You do not have access to this item" etc.). These are shown on screen, in a ASP.NET AJAX callback handler. The rest of the app is covered by some custom error pages, specified in the usual way in web.config. <customErr...

Is it possible to intercept WIN32 Exceptions for 3rd party applications?

Is it possible to intercept WIN32 exceptions for 3rd party applications? I have a particularly bad behaving 3rd party application for which I'm try to intercept unhandled exceptions so I can know that I need to kill the process but I'm finding it hard to find anything about this subject that seems to fit what I need. Any help would be...

If .Create() can't instantiate, should it return empty object, null, or throw an exception?

I want to be able to instantiate any object in my application with this kind of code: SmartForm smartForm = SmartForm.Create("id = 23"); Customer customer = Customer.Create("id = 222"); I'm now debating what Create() should return if that object does not exist. if Create() returns an empty object, then this is kind of a "null patter...

PHP - Converting all Errors to Exceptions - Good or Bad?

I was wondering if it's considered a bad practice to globally convert all PHP Errors to Exceptions. Something like the following would be used: function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); return false; } I suppose the assumption is ...

Several catch blocks or one with dynamic_cast?

We have a hierarchy of exception classes - there's a GenericException class and a number of classes that derive from it. GenericException is polymorphic - it has a virtual destructor. One of derived classes is FileException thrown to indicate errors when manipulating with filesystem objects. FileException has GetErrorCode() method that ...

Access Violation probem with unhandled managed Exceptions in managed C++ .NET application

This is actually a solved problem, but it's so esoteric I thought I'd share it for other users. Also perhaps others might suggest reasons? Anyway, I'm working on a "mixed mode" .NET application written in managed C++, but with heavy links into existing native libraries. The problem was, unhandled managed exceptions ended up as Win32 A...