exception-handling

Email notifications of exceptions happening in a Python app?

UPDATE: This is a Django web app Hi folks, I want to set up email notifications when there is an error happening in my application. In ruby, there is a very elegant solution called ExceptionNotifier, which wraps around the exception handler and uses the built-in mailer to send an email. What is the best way of doing this in Python? I k...

On null pointer arg, better to crash or throw exception?

Possible Duplicate: design by contract tests by assert or by exception? What is the preferred way to handle a null pointer passed in as an output argument to a function? I could ASSERT but I feel like its not good to let a library crash the program. Instead, I was thinking about using exceptions. ...

how to: handle exceptions, best practices

need to implement a global error handling, so maybe you can help out with the following example... i have this code: public bool IsUserAuthorizedToSignIn(string userEMailAddress, string userPassword) { // get MD5 hash for use in the LINQ query string passwordSaltedHash = this.PasswordSaltedHash(userEMail...

Exception handling problem in release mode

I have application with this code: Module Startup <STAThread()> _ Public Sub Main() Try Application.EnableVisualStyles() Application.SetCompatibleTextRenderingDefault(False) InitApp() Dim login As New LoginForm() Dim main As New MainForm() Application.Run(login) If login.DialogResult...

Sending an email when an Exception is Thrown

Hi: I have written a java class where if a method throws an exception, an email is sent, via java mail, with a report to the administrators. It works - my question is w.r.t elegance - to catch the exception thrown by the main method, the sendEmail() method resides in the catch block of the main method. The sendEmail() method has its o...

How Do I Handle errors in Windows Applications

I did a program and in some point - when the program needs to exit he throw an exception here is the code try { Application.Run(new Form1()); } catch (ExitException) { } In the VS it's working fine (VS 2008 - C#) But when I run it separately from the VS - the program say so the error is not handled I know so I can do like this A...

In Java, how do I set a return type if an exception occurs?

hey all, I'm new to Java and was wondering if I define a method to return a database object like import java.sql.*; public class DbConn { public Connection getConn() { Connection conn; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); if(System.getenv("MY_ENVIRONMENT") == "develo...

HttpWebRequest.GetResponse() - what specific status codes cause an exception to be thrown?

I've hunted around for some definitive documentation on this but haven't had much luck finding any. Basically - the question is - for which HTTP Status codes coming back from the server will HttpWebRequest.GetResponse() generate a WebException after doing something like say, a POST? Specifically - will it generate a WebException for an...

How do I propagate an exception thrown by croak in forked child to parent/foreground process?

Throwing an exception via croak in a forked child process seems to print the error as a background process would. That is, it clobbers the shell prompt. If I die instead of croak, the the error message pops up as a foreground process. I've trying to find out why that is in the Carp documentation without any luck. Here's what I mean. Th...

Execute plugin on MojoExecutionException

Is there a way to catch the MojoExecutionException in a "global way"? Example: My plugin performs some tasks. Later the build phase proceeds and an error occurs so an exception is thrown. I would like to catch that exception somehow and perform a clean up, or execute another plugin, etc. Is there a way to do this? Can't find anything...

COM: How to handle a specific exception?

i'm talking to a COM object (Microsoft ADO Recordset object). In a certain case the recordset will return a failed (i.e. negative) HRESULT, with the message: Item cannot be found in the collection corresponding to the requested name or ordinal i know what this error message means, know why it happened, and i how to fix it. But ...

In a client-server relationship, should the server always rethrow the exception to the client?

I have a set of web services (the server), and an app which consumes this (client). In this sort of relationship, should the server always throw exceptions (ie in the throw block, rethrow the caught exception), and the client catch this. Exceptions which the server can handle, it will deal with and not rethrow, but everything else will b...

New HandleProcessCorruptedStateExceptions attribute in .NET 4

I'm trying to crash my WPF application, and capture the exception using the above new .NET 4 attribute. I managed to manually crash my application by calling Environment.FailFast("crash");. (I also managed to crash it using Hans's code from "How to simulate a corrupt state exception in .NET 4?".) The application calls the above crashin...

Exceptions from WCF

What exceptions can be thrown from a WCF client? I usually catch CommunicationFaultedException, CommunicationException, TimoutException and some other but from time to time new ones occur, e.g. most recently QuotaExceededException There is no common base to catch (except Exception) so does anyone have a complete list? ...

Try catch finally blocks.. do i still need them when handling errors in the global.asax?

I am handling errors via my global.asax in this method: Dim CurrentException As Exception CurrentException = Server.GetLastError() Dim LogFilePath As String = Server.MapPath("~/Error/" & DateTime.Now.ToString("dd-MM-yy.HH.mm") & ".txt") Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(LogFilePath) sw.WriteLine(DateTime.Now....

DUMP in unhandled C++ exception

In MSVC, how can I make any unhandled C++ exception (std::runtime_error, for instance) crash my release-compiled program so that it generates a dump with the full stack from the exception throw location? I have installed NTSD in the AeDebug registry and can generate good dumps for things like memory access violation, so the matter here ...

R : catching errors in `nls`

I'm fitting some exponential data using nls. The code I'm using is: fit <- nls(y ~ expFit(times, A, tau, C), start = c(A=100, tau=-3, C=0)) expFit is defined as expFit <- function(t, A, tau, C) { expFit <- A*(exp(-t/tau))+C } This works well for most of my data, for which the starting parameters provided (100, -3 and ...

Mapping the System.Exception with FaultException

I have used exception sheilding feature of application block, to map System.Exception with class that is marked as DataContract. It works very well. But When I have mapped the System.Exception with FaultException, I got the below error message. "An error has occurred while consuming this service. Please contact your administrator for mo...

c++ try catch practices

Is this considered good programming practice in C++: try { // some code } catch(someException) { // do something } catch (...) { // left empty <-- Good Practice??? } ...

Ignore a Specific Typed Expection

I would like to ignore a specific Type of exception in a group of statements; without having to put empty Try..Catches around them. try{ o1.Update(); } catch (Exceptions.NoChangeMade ex) {} try{ o2.Update(); } catch (Exceptions.NoChangeMade ex) {} try{ o3.Update(); } catch (Exceptions.NoChangeMade ex) {} I would like either a On Error...