exception-handling

How do I add my own data to an Exception in MVC?

Will's Error handling post is awesome! I'm not yet using ELMAH, but I'd like to start adding some of my own data to the Exception on a per Controller basis. Right now, I have a base controller overriding OnException(ExceptionContext) as per Will from which all project Controllers inherit. I think I understand I'll need to customize ano...

Java: Meaning of catch (final SomeException e) ?

What does "final" do in the following Java expression? catch (final SomeExceptionType e) ...

System.exit(num) or throw a RuntimeException from main?

I've got a single threaded app that should set the DOS errorlevel to something non-zero if there is a problem. Is it better to throw a RuntimeException, or to use System.exit(nonzero)? I don't need the stack trace, and I don't expect this app to be extended/reused. What are the differences between these two options? ...

Exception handling in Python

http://docs.python.org/library/imaplib.html states that: exception IMAP4.error Exception raised on any errors. The reason for the exception is passed to the constructor as a string. What does "exception is passed to the constructor as a string" mean? What would the code look like that can print the reason. ...

Better way to retry a statement that threw an exception in vb.net

I usually do something like this: Dim Attempts = 0 Try Retry: <Block> Catch If Attempts < 3 Then Attempts += 1 Thread.Sleep(2000) GoTo Retry Else Throw End If End Try This is really bad looking for me, but i don't know of a better way of do...

trapping and logging "bugfoot" javascript exceptions in a meaningful way

We have had some reports of problems with our checkout whereby customers get js exceptions (we assume) so they cannot checkout. No matter how many testbenches we use, we have failed to recreate the issues but that's the point of the exercise. I have setup a simple error trapping function which works based around: window.onerror = fun...

Can throwing Exception be a good way to handle all of the exceptions that are thrown in Java's reflection API?

I find that Java's reflection API is exception verbose, and I often want to catch each specific exception, but just throw Exception. Is this poor practice, or do you really throw all of those exceptions on the method signature? Every method that calls that method must then deal with each of those specific exceptions in some way. Instead,...

Exception Notification Gem and Rails 3

I'm trying to get this up and running, but I see "uninitialized constant ExceptionNotifier" whenever I start my server. http://github.com/rails/exception_notification In my Gemfile I have gem "exception_notification", :git => "http://github.com/rails/exception_notification.git", :branch => "master" I've tried putting the configurati...

Exception handling try catch inside catch

I recently came across a code written by a fellow programmer in which he had a try catch statement inside a catch! Please forgive my inability to paste the actual code, but what he did was something similar to this try { //ABC Operation } catch (ArgumentException ae) { try { //XYZ Operation } catch (IndexOutOfRangeEx...

Standard way of handling errors originating from threads

This question has been brought up many times, but I'd like to ask it again because I've read some things here that didn't seem right to me (could be because one is related to the .NET CF), and I am asking for validation of a specific approach that I think is reasonable, and would appreciate any feedback you might have. Anyhow, the situa...

Terminating app due to uncaught exception 'NSInvalidArgumentException'

Hello, I am using ShareKit to allow the user to share their score on Twitter and Facebook in my iPhone app. However, it seems to crash shortly after sharing on either service. I get an console message which says: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString rangeOfString:options:...

Catch a run-time exception

Following fails to catch a exception int *i; //intentionally uninitialized try { *i = 6; } catch (const runtime_error e) { cout << "caught!" << endl; } is it actually catching a runtime error or an exception? ...

Handling Exceptions thrown in Zend Framework's Controller Plugins

Hi I have an Acl plug-in which extends Zend_Controller_Plugin_Abstract, this plug-in handles all my Acl code. I want to thrown an Exception in this plug-in, e.g. an Exception_Unauthorised and then handle this in my ErrorController, this way I can use the same Acl plug-in for different applications and use the ErrorController to handle ...

Are exceptions in php really that useful?

Hello, 3 days ago I started rewriting one of my scripts in OOP using classes as a practice after reading a lot about the advantages of using OOP. Now I'm confused weather I should use exceptions or not. They seem to make my work harder and longer. My application check if the data was sent through an Ajax request or not then uses that i...

Subclassing exceptions

We all agree that using different exception types for different tasks is the way to go. But then, we end up with creating ghost files like this: /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the w...

How should I handle an exception with ASP.NET MVC partial views?

I have a partial view (ascx) for displaying the top x articles of a person's RSS feed: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Models.Article>>" %> <% foreach (var item in Model) { %> <a href="<%: item.Url %>"><%: item.Title %></a><br /> <%: String.Format("{0:g}", item.Date) %...

how to not throw exceptions to server.log in java

In my application I am using log4j and have a my_system.log where all the messages should be thrown. Problem I have is that when an error happens it is also showing up in server.log (I don't want this to happen). public String getAccessFlag (String userId, String participantCode, String roleId) { HashMap parmMap = new HashMap(); ...

Guidelines on Exception propagation (in Java)

Are there any guidelines on exception propagation in Java? When do you add an exception to the method signature? For example: if an exception is only thrown when an essential program resource is missing, and can only be handled at the top level, do I propagate it through all methods using this exception through all the methods using the...

Throw VS rethrow : same result ?

Hello, refering to a lot of documentation on the net, particularly on SO, eg : http://stackoverflow.com/questions/178456/what-is-the-proper-way-to-re-throw-an-exception-in-c there should be a difference between "throw e;" and "throw;". But, from : http://bartdesmet.net/blogs/bart/archive/2006/03/12/3815.aspx, this code : using System...

Ideal error page for J2EE App

I'm having a tough time consolidating errors in my application. Currently, my error.jsp looks like following (part of it): <%@ page isErrorPage="true" %> <%@page contentType="text/html"%> <%@page import="java.util.*"%> <%@page import="javax.servlet.*"%> <%@page import="javax.servlet.http.*"%> <%@page import="java.util.Calendar"%>...