error-handling

What is the best way to return errors from a WCF service in a RESTful way?

Using WCF in a RESTful way seems great. I’m a big fan of the big guns like simplicity and flexibility, but I also love the way the Urls end up looking. What can I say, I’m a programmer. The simple API for retrieving and editing resources is matched by an almost equally simple set of possible error responses, and I can’t help feeling tha...

How should I handle errors in Perl methods, and what should I return from the methods?

Hi I've wrapped Perl's Net::SSH::Expect with a small module to reduce the boilerplate code needed to write a new configuration script for use with our HP iLO cards. While on one hand I want this wrapper to be as lean as possible, so non-programmer colleagues can use it, I also want it to be as well-written as possible. It's used like s...

Where do you like to catch exceptions and why?

Where do you like to catch exceptions and why? I'm interested in seeing where people find it useful to put their try/catch blocks in the hope that some general patterns might emerge. I'll post my two example answers in C++ but any language is fine. One location and reason per answer please. Thanks. ...

ASP.NET AJAX WebForms custom error handling question

I've made a web application that has the following architecture: Every form is a UserControl, there is just one actual page (Default.aspx), and a parameter in the URL specifies which UserControl to load. The UserControl is loaded in an UpdatePanel so that it can enjoy full AJAX-iness. There is also an elaborate message displaying mechan...

Puzzled by Rails exception notification system.

[update2] One of those problems I solved & can't remember how... :) [update1] could this be a problem in the model? PAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/paypal_cert.pem") APP_CERT_PEM = File.read("#{Rails.root}/certs/app_cert.pem") APP_KEY_PEM = File.read("#{Rails.root}/certs/app_key.pem") The page I'm trying to ac...

How can I get around a 'die' call in a Perl library I can't modify?

Yes, the problem is with a library I'm using, and no, I cannot modify it. I need a workaround. Basically, I'm dealing with a badly written Perl library, that exits with 'die' when a certain error condition is encountered reading a file. I call this routine from a program which is looping through thousands of files, a handful of which ar...

How should I use FormatMessage() properly in C++?

Without: MFC ATL How can I use FormatMessage() to get the error text for a HRESULT? HRESULT hresult = application.CreateInstance("Excel.Application"); if (FAILED(hresult)) { // what should i put here to obtain a human-readable // description of the error? exit (hresult); } ...

C++: Error handling problem across threads

In general I use exceptions to deal with errors, however the problem I have here is that the error applies to a different thread than the one that caused it. Basicly the window has its own thread, and the direct3d device must be created and reset by the same thread that created the window. However creating the device may fail, so I need...

Logical Operators: is AND better than OR?

Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing something obvious. So let's say some user input throws an error, and I want to catch it and return some feedback. The error will be a number, 0 - 8. 0 means "No Error". I want to give the user very specific feedback if the error is 3 (No numbers allowed, let's say)...

How to put error handlers in all vb functions

We have multiple vb projects.We want to put error handlers in all functions, and error handler should write to a file.Are there any tools available - we have looked at codesmart and vbwatch. ...

Is try-catch like error handling possible in asp classic

What options are there in asp for error handling. For example: I'm using the Mail.SendMail function but when switching on the testing server it doesn't work, which is normal. I want to test if mailing is possible, if not then continu and/or show a message. Any ideas? ...

Prevent "Send error report to Microsoft"

I'm working on a rather large project, and its unlikely will catch everything. I've found the event that notifies me of unhandled exceptions, however I haven't found a way to programmatically shut off the windows error dialog. Ideally, if there is an unhandled exception, I would like to have that event fired, provide a dialog box telling...

Globally log exceptions from ASP.NET [ScriptService] services

I'm using the [System.Web.Script.Services.ScriptService] tag to use web services callable from client side javascript. What I need is a way of globally logging any unhandled exceptions in those methods. On the client side, I get the error callback and can proceed from there, but I need a server-side catch to log the exception. The guy...

What are the best practices for returning errors from functions?

Hi, I usually do something like the example below when I need to return error messages from a function, if no errors occur I just return an empyty string. Is this best practice, or are there alternatve ways of returning error messages from functions? Function Test() as String ' Do something If error occured Then Return "Some...

Catch exceptions in jQuery

Hello, I have the following code: <script type="text/javascript"> $(document).ready(function() { $("#Save").click(function() { $.post("url", { "data": "data" }, function(data) { alert(data); }); }); }); </script> I'm testing this script, an...

How do I gracefully exit a MDI form that has code executing in Delphi

I have a MDI application written in Delphi 2007. If the user exits a form within it whilst code is executing it causes an exception, because the code is trying to update a component or use an object that has been freed with the form. Is there anyway I can tell if code is executing in the exit event or is there a standard way to deal wi...

Handling possible errors with network drive file I/O

I'm trying to make file I/O over a network drive (likely over a WAN or VPN) as reliable as possible for a native C++ Windows app... What are the possible error conditions that I need to be able to handle? How can I simulate these error conditions in testing? How do I get detailed information on a particular error? For example, if fop...

server side validation, how to pass errors to view in MVC?

Hi, Using .net MVC and I am doing some server side validation in my Action that handles the form post. What is a good technique to pass the errors back to the view? I am thinking of creating an error collection, then adding that collection to my ViewData and then somehow weave some javascript (using jQuery) to display the error. It w...

Does ActionScript 3 require an error event handler for XML?

In a Flash game I am developing, there are some settings that are set by an external XML file. When I run the SWF file through the Flash IDE, it loads fine. If I run the same file as a projector (.exe) or the independent SWF file, it does not load the XML file. My (unexpected) fix was to assign an error event listener to the loader ob...

How is the C++ exception handling runtime implemented?

I am intrigued by how the C++ exception handling mechanism works. Specifically, where is the exception object stored and how does it propagate through several scopes until it is caught? Is it stored in some global area? Since this could be compiler specific could somebody explain this in the context of the g++ compiler suite? ...