error-handling

Get exception context in PHP

If you use a custom error handler in PHP, you can see the context of an error (the value of all variables at the place where it occurred). Is there any way to do this for exceptions? I mean getting the context, not setting an exception handler. ...

Error Logging and Exception Notififcation Library

For any serious software application, error logging and a feedback mechanism is simply indispensable. After you have captured the error log a log file ( maybe using something like log4net), or maybe during the time when an exception occurs, you want to prompt out a message box ( see below image), apologizing for the problem, and ask the ...

Error handling inside or out of class?

Usually I do all what I can inside a class, in every method (try and catch). Am I doing it wrong? Recently I heard better way is handle error in program body... What is good habit? ...

do you see any problem with that stored procedure template?

so I created that(I used some stuff found on other website) to handle transactions and having a sort of stacktrace while executing stored procedure that could call other stored procedure that need transaction and etc. so if I have A calling B and B is calling C and C got an error, I can correctly rollback my stuff and returning a stackt...

Why does $.ajax call for json data trigger the error callback when http status code is "200 OK"?

I have the following ajax request: jQuery.ajax({ async: true, type: "GET", url: url, data: data, dataType: "json", success: function(results){ currentData = results; }, error: function(xhr, ajaxOptions, thrownError){ if (xhr.status == 200) { console.debug("Error code 200"); } else { cu...

c++: Operator overloading and error handling

Hi, I am currently starting to look into operator overloading in c++ for a simple 2D vertex class where the position should be available with the [] operator. That generally works, but I dont really know how to deal with errors for instance if the operator is out of bounds (in the case of a 2D vertex class which only has x and y values,...

Is assert evil?

The Go language creators write: Go doesn't provide assertions. (...) Programmers use them as a crutch to avoid thinking about proper error handling and reporting. What is your opinion about this? ...

Can I rollback Dynamic SQL in SQL Server / TSQL

Can I run a dynamic sql in a transaction and roll back using EXEC: exec('SELECT * FROM TableA; SELECT * FROM TableB;'); Put this in a Transaction and use the @@error after the exec statement to do rollbacks. eg. Code BEGIN TRANSACTION exec('SELECT * FROM TableA; SELECT * FROM TableB;'); IF @@ERROR != 0 BEGIN ROLL...

How to catch this error? [C++]

Hi, I'm trying to catch dividing by zero attempt: int _tmain(int argc, _TCHAR* argv[]) { int a = 5; try { int b = a / 0; } catch(const exception& e) { cerr << e.what(); } catch(...) { cerr << "Unknown error."; } cin.get(); return 0; } and basically it doesn't work. Any advice why? Thank you. P.S. Any chance that in the future code...

Custom Error Handling in ASP.NET MVC

I've tried implementing the answer listed here: Properly handling 404s which came from this blog post: Real World Error Handling All I get is a blank page. I step through the debugger and I see the Exception catch, the ErrorController method get called and the return of the View execute, but then I don't see anything in the web browser...

Alternative to returning mixed errors and booleans.

I have a (common) situation where I am currently returning a result that is a mixed type, sometimes a boolean, sometimes an error message. For example: function checked_thing_is_legal(){ // Do stuff and check for errors in here. } // Returns true if there are no errors, otherwise returns an error message string. This feels dirty, an...

JQuery error property for error handler

Hello all, I'm just playing around for the first time with jQuery's ajax functionality. I wanted to add a function that could handle any errors. So, in one of my client javascript blocks, I added the following line: <script type="text/javascript"> .... $.ajax({ error: function () { alert('boo'); } }) .... </script> I expe...

What information should/shouldn't an error page display in a web application?

I'm developing a number of error views for an ASP.NET MVC application (a not-found, unknown and general error view) and I'm curious to know how others would answer these questions: What kind of verbage do you include on these pages? What kind of information do you display to the end user? What information do you log? I don't think th...

What are some common SocketExceptions and what is causing them?

I've been caught catching SocketExceptions belonging to subspecies like for example Broken pipe or Connection reset. The question is what to do with the slippery bastards once they're caught. Which ones may I happily ignore and which need further attention? I'm looking for a list of different SocketExceptions and their causes. ...

Uniformly handling error codes in an unmanaged API

I'm writing a wrapper around a fairly large unmanaged API. Almost every imported method returns a common error code when it fails. For now, I'm doing this: ErrorCode result = Api.Method(); if (result != ErrorCode.SUCCESS) { throw Helper.ErrorToException(result); } This works fine. The problem is, I have so many unmanaged method ca...

In ASP.Net MVC, can ModelState be used with an ajax update?

This is a follow up to a previous question that I had before about passing an error back to the client, but also pertains to the ModelState. Has anyone successful used the Nerd Dinner approach, but with Ajax? So Nerd Dinner does an update as so. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, FormCollection formValue...

What is IDataErrorInfo and how does it work with WPF?

While working on some custom validators in WPF, one of my co-workers pointed me out the IDataErrorInfo. I have a sample view in XAML that has a textbox and a button. Based on the value in the textbox I would like the button to be either enabled or disabled. My co-worker suggested that extending the IDataErrorInfo in the presentor of my v...

TCP send/recv error reporting

I have a client/server program (Windows, winsock2) which communicates over TCP. The client connects and sends data to server (using send) in 8K at a time. The server just reads data (using recv). No special settings done on sockets. Problem: When some network error occurs during the communication (e.g. cable pulled out), receiver do no...

Logging errors on Windows 2003 Server using the EventLog class

I've tried logging errors in my application, using the EventLog class.. But the Event Viewer on Windows 2003 Server is very limited as far as displaying the stuff I log. Here's what I'm doing: if (!EventLog.SourceExists("TestApp.exe")) { EventLog.CreateEventSource("TestApp.exe", "TestApp"); } EventLog.WriteEntry("TestApp.exe", Exc...

Handle "potentially dangerous Request.Form value..."

Hi, What's the best way to handle errors such as "A potentially dangerous Request.Form value was detected from the client" in ASP.NET? I'd like to keep the validation on, as my forms have no valid reasons to be allowing HTML characters. However, I'm not quite sure how to handle this error in a more friendly manner. I tried handling it ...