error-handling

Check Contraint Bypassing CATCH block in Distributed Transaction

Hello, I have a MSSSQL stored procedure performing a distributed transaction that looks like this: SET XACT_ABORT ON; SET NOCOUNT ON; BEGIN TRY BEGIN DISTRIBUTED TRANSACTION insert into LNKSRV.INST.dbo.zz (id, val) values (1, 'a'); insert into LNKSRV.INST.dbo.zz (id, val) values (2, 'b'); COMMIT TRANSACTION END TRY BEGIN C...

How do I capture/log SQL Server 2005 "Attention" events?

This is in reference to this question here: http://stackoverflow.com/questions/546781/check-contraint-bypassing-catch-block-in-distributed-transaction Apparently in that distributed transaction scenario, an "attention event" is sent to our sql server and is destroying the connection without giving us the opportunity to log the error in...

Debug-compiled executable: Why not abort gracefully on invalid write to NULL?

What I don't understand about C/C++ is: Yes, everyone uses it to get blazingly fast executables, so they compile with optimization turned on. But for compilation with debug information turned on, we don't care about speed. So why not include more information in that compile mode, for example detect some segfaults before they happen? E...

python runtime error, can dump a file?

I am using libcurl to DL a webpage, then i am scanning it for data and doing something with one of the links. However, once in a while the page is different then i except thus i extract bad data and pycurl throws an exception. I tried finding the exception name for pycurl but had no luck. Is there a way i can get the traceback to execut...

Is there an equivalent for SQL Server's @@error in MySQL

I want to run an update query against a production database and as good little developer I am trying to make it as safe as possible. I am looking to do the following BEGIN TRANSACTION UPDATE table_x SET col_y = 'some_value' . . . IF (@@error <> 0) BEGIN ROLLBACK END ELSE BEGIN COMMIT END The above should work i...

Catching segfaults in C

I have a program that segfaults from pointer arithmetic sometimes. I know this happens, but I can't easily check ahead of time to see whether it segfaults or not - either I can "pre-scan" input data to see if it will cause a segfault (which can be impossible to determine), or I can refit it to not use pointer arithmetic, which would requ...

Error Codes and Messages Best Practise

I am planning out an EDI system that sends, amongst other things, an XML acknowledgement message containing several elements, but specifically these three; ErrorCode, ErrorSeverity and ErrorDescription. I will basically be parsing an inbound XML message and depending upon success or failure of parsing to include message formatting, synt...

In case of unhandled code exceptions, what is the most appropriate thing to show the end user?

In a web application, when your server side code screws up and experiences an unhandled exception, what is the most appropriate way to tell the end users of what happened? Do you simply say "Something unexpected happened and we are sorry". Should you try to make some sense of what the exception was and what the user was trying to do and ...

Accessing ASP.Net MVC site without www throws an error

Hi, This one is causing me a few nightmares as I'm on the live box trying to work out what is going wrong! If someone accesses our ASP.Net MVC website with the full URL http://www..net all is OK. If they go to: http://.net then our custom error page is shown. This used to work OK before we moved the site to MVC. We do have an Appl...

How do I override the error message on a databound control in WinForms?

I have a form in my application that uses a binding source to bind the controls to a model object. This works, and handles basic validation such as ensuring that the user doesn't enter text into a numeric field, for example. I am using an ErrorProvider, and setting its datasource = the binding source in order to display the error messag...

Logging errors in ASP.NET MVC

I'm currently using log4net in my ASP.NET MVC application to log exceptions. The way I'm doing this is by having all my controllers inherit from a BaseController class. In the BaseController's OnActionExecuting event, I log any exceptions that may have occurred: protected override void OnActionExecuted(ActionExecutedContext filterCont...

Bash: How do I check if certain files exist?

In a bash script, I have to check for the existence of several files. I know an awkward way to do it, which is as follows, but that would mean that my main program has to be within that ugly nested structure: if [ -f $FILE1 ] then if [ -f $FILE2 ] then echo OK # MAIN PROGRAM HERE fi fi The following version does not work: ([ -f ...

How to handle db constraint violations in the user interface?

We implement the majority of our business rules in the database, using stored procs. I can never decide how best to pass data constraint violation errors from the database back to the user interface. The constraints I'm talking about are tied more to business rules than data integrity. For example, a db error such as "Cannot insert dup...

Should I ignore the occasional Invalid viewstate error?

Every now and then (once every day or so) we're seeing the following types of errors in our logs for an ASP.NET 3.5 application Invalid viewstate Invalid postback or callback argument Are these something that "just happens" from time-to-time with an ASP.NET application? Would anyone recommend we spend a lot of time trying to diagnose...

Is there a pattern for propagating details of both errors and warnings?

Is there a common pattern for propagating details of both errors and warnings? By errors I mean serious problems that should cause the flow of code to stop. By warnings I mean issues that merit informing the user of a problem, but are too trivial to stop program flow. I currently use exceptions to deal with hard errors, and the Python l...

ASP.NET Error Handling

In my asp.net applications, I've typically used the Application_Error global event handler to log the error and redirect the user to a user-friendly error page. However, I have read about ELMAH and while that seems interesting, Application_Error seems like the simpler approach. I've read other questions where people, including myself...

JAX-RS / Jersey how to customize error handling?

I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( @QueryParam("name") String name, @QueryParam("birthDate") Date birthDate) { // ...

When is it appropriate to use C++ exceptions?

I'm trying to design a class that needs to dynamically allocate some memory.. I had planned to allocate the memory it needs during construction, but how do I handle failed memory allocations? Should I throw an exception? I read somewhere that exceptions should only be used for "exceptional" cases, and running out of memory doesn't seem ...

What is the best exception handling strategy within error logging classes?

I am writing an error logging set of classes which will log to file, event log etc. What exception handling should be performed within these classes? For instance, say I have a LogError method, which is called from exception handlers, and writes to file. What is considered the best thing to do, should an error occur? Obviously, I should ...

how to check errors from Web Services

Hello everyone, I am developing ASP.Net asmx web services. And at client side, if the request to server returns Http error code, like http 500, how could I know from web services client side (I use the automatically generated client proxy by using add web references)? thanks in advance, George ...