I have a c# program which throws a NullReferenceException(). When I start this on my Vista machine, it gives the familiar screen "Foo has stopped working". I can easily click on 'details' to see what went wrong. On one XP machine there's no warning at all: the program just quits, and on another XP I get the "Foo has encountered a problem...
I would like to catch the error and show the appropriate message if the ajax request fails.
My code is like the following, but I could not manage to catch the failure ajax request.
function getAjaxData(id)
{
$.post("status.ajax.php", {deviceId : id}, function(data){
var tab1;
if (data.length>0) { ...
Given following ASP.NET MVC controller code:
[HttpPost]
public ActionResult Create(FormCollection collection)
{
string[] whitelist = new []{ "CompanyName", "Address1", "Address2", ... };
Partner newPartner = new Partner();
if (TryUpdateModel(newPartner, whitelist, collection))
{ ...
Hi,
I have a question regarding error checking in Python. Let's say I have a function that takes a file path as an input:
def myFunction(filepath):
infile = open(filepath)
#etc etc...
One possible precondition would be that the file should exist.
There are a few possible ways to check for this precondition, and I'm just won...
It would appear that catching an error is slower that performing a check prior to the error (for example a TryParse). The related questions that prompt this observation are here and here.
Can anyone tell me why this is so - why is it more costly to catch an error that to perform one or many checks of the data to prevent the error?
...
I'm working on a personal website and I'm using webforms and .NET 3.5 and C#. I'm trying to get the custom error pages sorted but I can't get them to work properly. Not on my local IIS 7.5 as on the external server. It keeps prompting me with default IIS error pages when pages can't be found. How can it be fixed?
I've got the following ...
Hi,
how should I handle an exception that occurs after sending a Content-Disposition header for an attachment? I'm trying to generate a report at server and send it as a file, but if an exception occurs during the report generation, the error message itself is sent to browser which still takes it as a content of a file and shows a Save ...
Hi StackOverflow,
I'm very new to OOP, and in the program I'm working on, I have an Utilities class that contains some general methods. Should I include my error checking in the Utilities class or should I create a new class just for error checking?
...
In writing Win32 C++ code, I'd appreciate some hints on how to handle errors of Win32 APIs.
In particular, in case of a failure of a Win32 function call (e.g. MapViewOfFile), is it better to:
use AtlThrowLastWin32
define a Win32Exception class derived from std::exception, with an added HRESULT data member to store the HRESULT correspo...
Hi all. I am not an expert on SQl Server. Is this a valid pattern for handling errors in a batch of SELECT, INSERT...in SQl SERVER ? (I use v.2008)
BEGIN TRANSACTION
BEGIN TRY
-- statement 1
-- statement 2
-- statement 3
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END ...
I'm learning Perl, and in a lot of the examples I see errors are handled like this
open FILE, "file.txt" or die $!;
Is die in the middle of a script really the best way to deal with an error?
...
I'm using IErrorHandler to do exception handling in WCF and now I want to log the exceptions, along with the stack trace and the user that caused the exception.
The only way I can see to get the user that caused the exception is:
OperationContext.Current.IncomingMessageProperties.Security.ServiceSecurityContext.PrimaryIdentity
...But ...
I'm creating a messaging web app in ASP.NET and are having some problems when displaying an error message to the user if they go to send a message and there is something wrong.
A user can look through profiles of people and then click, 'send a message'. The following action is called (url is /message/create?to=username) and shows them ...
I'd like to indicate to SQL Server 2005, in my BEGIN CATCH...END CATCH block that the error is "handled"... That is, clear the error.
Is that possible? Consider this:
begin transaction
begin try
begin transaction
select cast('X' as bit)
commit transaction
end try
begin catch rollback transaction
select...
My goal is to have an error bean returned on a 404 with a descriptive message when a object is not found, and return the same MIME type that was requested.
I have a look up resource, which will return the specified object in XML or JSON based on the URI (I have setup the com.sun.jersey.config.property.resourceConfigClass servlet paramet...
May I ask should the error catching code be placed at the lowest level or at the top as I am not sure what is the best practice? I prefer placing at the bottom, example a, as
Example a
public static void Main(string[] args)
{
string operation = args[0];
int value = Convert.ToInt32(args[1]);
if (operation...
I am trying to capture database (MYSQL) errors in my PHP web application. Currently, I see that there are functions like mysqli_error(), mysqli_errno() for capturing the last occurred error. However, this still requires me to check for error occurrence using repeated if/else statements in my php code. You may check my code below to see w...
Hi everybody,
We have a web server that we're about to launch a number of applications onto. They will all share database and memcached servers, but each application has it's own mySQL database and all memcached keys per application, is prefixed.
Possible scenario:
If a memcached server in our cluster goes boom, we want someone (opera...
So I'm trying to write a simple TCP socket server that broadcasts information to all connected clients. So when a user connects, they get added to the list of clients, and when the stream emits the close event, they get removed from the client list.
This works well, except that sometimes I'm sending a message just as a user disconnects...
Hi!
I am well aware about error_reporting(0); & ini_set('display_errors', "Off"); to make error messages go away.
What would be an appropriate way to do this - for a specific file or part of code only?
Surpressing errors with @'s seems like a bad idea since it apparently slows the code down...
The reason? We have a number of memcach...