error-handling

Getting Line Numbers for Errors Thrown in SQL Server CLR Runtime

Hi all, I've created a CLR stored procedure that I'm running on SQL 2k5 and I'm wondering if there's any way to get line numbers for exceptions thrown by the .NET code. When an Exception is thrown, I get something along the lines of Msg 6522, Level 16, State 1, Procedure myProcedure, Line 0 A .NET Framework error occurred during exec...

MS-Access, VBA and error handling

This is more an observation than a real question: MS-Access (and VBA in general) is desperately missing a tool where error handling code can be generated automatically, and where the line number can be displayed when an error occurs. Did you find a solution? What is it? I just realized how many hundreds of hours I spared since I found th...

Internet Explorer: What happens when you select a non-existing file for upload in an HTML form?

On Internet Explorer, the standard HTML file upload form also allows for direct input of the file name (instead of using the file selector dialog). This makes it possible to enter non-existing files. On other browsers (which do not let you do that) I suppose this case can still occur if you delete the file after having selected it. In o...

Why Error handling is important?

I was given a task of write the coding guidelines for my team, and it was going great until my manager asked me to write an explanation of Why Error Handling is Important. I know it instinctively, but how do I put this down into words? I tried to google it fisrt but came up empty, so I ask my fellow coding whiz, for an answer. ...

How do I show Error Message using Managed Custom Actions with Windows Installer

I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling: Dim record As New Record(1) ' Field 0 intentionally left blank ' Field 1 contains error number record(1) = 275...

Custom Error handling in ASP MVC

I want to go beyond the default error handling given in ASP mvc. I have an errors controller, so I can hopefully give different error messages according to whats happened: i.e Invalid arguments, Permission denied, OMG DATABASE DEAD, etc. But I cant seem to work out how to do this, this is what I have tried: [HandleError(View="/Errors/...

How do you test a file.read() error in Python?

I have the following code (adapted from an example given in Dive Into Python) that reads the entire contents of a file into a buffer. buffer = "" try: file = open(postFileName, 'rU') try: # Read the entire POST log file into a buffer buffer += file.read() finally: file.close() except IOError: buf...

Error handling in C code

Hi! What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library. There are two ways I've been thinking of: Always return error code. A typical function would look like this: MYAPI_ERROR getObjectSize(MYAPIHandle h, int* returnedSize); The always provide an error pointer approach: ...

assert and NDEBUG

After reading some threads on misuses of exceptions (basically saying you don't want to unwind the stack if a functions preconditions are incorrect - possibly signalling that all your memory is corrupt or something equally dangerous) I'm thinking about using assert() more often. Previously I have only used assert() as a debug tool and I ...

What is a good Linux exit error code strategy?

I have several independent executable Perl, PHP CLI scripts and C++ programs for which I need to develop an exit error code strategy. These programs are called by other programs using a wrapper class I created to use exec() in PHP. So, I will be able to get an error code back. Based on that error code, the calling script will need to ...

ASP.NET Error Handling Question

I've been doing some research on how to globally handle errors in my ASP.NET application. I have settled on using the web.config file with the following code: <customErrors mode="On" defaultRedirect="errorpage.aspx"> </customErrors> Here is my errorpage.aspx.vb code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System....

What is the difference between exit() and abort()?

In C and C++, what is the difference between exit() and abort()? I am trying to end my program after an error (not an exception). ...

How do you set different web.config default error pages based on website section using ASP.NET MVC

I think this is pretty typical, you have the same website project with an "admin" section and a public facing section. In this website I want to configure the default errors, but I also want them to display in the correct layout. (the admin looks different than the public facing site). In webforms you could put a different web.config in...

How detailed should error messages be?

I was wondering what the general consensus on error messages was. How detailed should they be? I've worked on projects where there was a different error message for entering a number that was too big, too small, had a decimal, was a string, etc. That was quite nice for the user as they knew exactly where things went wrong, but the error...

Best practices for exception management in JAVA or C#

I'm stuck deciding how to handle exceptions in my application. Much if my issues with exceptions comes from 1) accessing data via a remote service or 2) deserializing a JSON object. Unfortunately I can't guarantee success for either of these tasks (cut network connection, malformed JSON object that is out of my control). As a result,...

Why are Exceptions said to be so bad for Input Validation?

I understand that "Exceptions are for exceptional cases" [a], but besides just being repeated over and over again, I've never found an actual reason for this fact. Being that they halt execution, it makes sense that you wouldn't want them for plain conditional logic, but why not input validation? Say you were to loop through a group of...

Commenting try catch statements

What is the proper place to explain error handling in a try-catch statement? It seems like you could put explanatory comments at either the beginning of the try block or the catch block. // Possible comment location 1 try { // real code } // Possible comment location 2 catch { // Possible comment location 3 // Error h...

When to use assertion over exceptions in domain classes

Are there any situations when you would use assertion instead of exceptions-handling inside domain classes... ...

Fatal errors in live servers

I'm writing some client/server software and I'm facing the following design issue. Normally, I use a VERIFY macro very liberally - if something is wrong in an user's machine, I want the software to fail and log the error so it can be fixed. I was never a fan of ignoring any kind of errors. However, I'm now writing a server. If the serve...

Which contract (Design by contract) is better?

Suppose I have a method public Patient(int id) { ---- } that returns Patient object given an id.. I could define contract in 2 ways Method would return null if patient does not exist Method would throw an exception if patient does not exist. In this case I would also define a query method that returns true if the Patient exist i...