Disclosure: the code I'm working on is for university coursework.
Background: The task I'm trying to complete is to report on the effect of different threading techniques. To do this I have written several classes which respond to a request from a client using Java Sockets. The idea is to flood the server with requests and report on how...
I have something like the following:
public class FooWrapper
{
public Action Foo { get; set; }
public void Execute()
{
try
{
Foo.Invoke();
}
catch (Exception exception)
{
//exception is null
//do something interesting with the exception
}
}
}
When I run my unit test with something like the following:...
Assume you have the following code:
Instead of doing:
Try
'
' Initialize some objects
'
'
' do something that fails
'
'
' Clean up-code that gets not reached because exception
'
Catch e As Exception
'
'Clean up initialized objects
'
Throw e
End Try
I would like to do:
Try
'
...
I was doing some unit testing on code that could throw a number of exceptions depending on the inputs. So I tried something like the below code: (simplified for the example)
static void Main(string[] args)
{
RunTest<ArgumentException>();
}
static void RunTest<T>() where T : Exception, new()
{
try
...
I've got a coding standards meeting in just over an hour and I need a quick answer to this one.
Common wisdom among experienced Java programmers is that you don't throw or catch java.lang.Exception (with rare exceptions - no pun intended). The reason you don't do this is that the statement
catch (java.lang.Exception ex) {...}
will ...
Is it possible to catch a stack overflow exception in a recursive C++ function? If so, how?
so what will happen in this case
void doWork()
{
try() {
doWork();
}
catch( ... ) {
doWork();
}
}
I am not looking for an answer to specific OS. Just in general
...
I have a recursive method call. When any exception is thrown, I would like to see, where in the recursive call stack it happened. I have a field which holds a "path" which represents the recursion stack.
Now I would like to add the path information to any exception that could possibly be thrown in the recursive call.
void Recursive(int...
I have an orchestration that uses a request response port to call to a web service and wait for a response.
This is working perfectly.
I am now doing tests to handle errors and I am calling a web service that throws a divide by zero exception.
The orchestration doesn't catch the exception as an exception; it acts as if the SOAP fault I ...
As is suggested elsewhere, I am using redirectMode = ResponseRewrite in my custom error configuration so my custom error page can access the exception info. This has worked like a charm for some time.
In adding some more "help the user recover from an error" type functionality, we need a piece of info that has been previously stored in...
Is there a facility similar to ELMAH but for non-ASP applications? One that will handle all unhandled exceptions and write them to multiple sources?
Or is there some way to easily capture all unhandled exceptions, similar to Application_Error in an ASP.NET Global.asax.cs file? If that can be done, I can then just use NLog or similar to ...
Exception log
javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.FileUploadFormatAdd_jsp._jspService(FileUploadFormatAdd_jsp.java:620)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(...
A C# program is invoked by:
Application.Run (new formClass ());
I'd like to put a try/catch around the whole thing to trap any uncaught exceptions. When I put it around this Run method, exceptions are not caught; control only returns here when the program terminates after an uncaught exception.
Where can I put try/catch to cover the...
Hey everyone, I was thinking about passing method blocks around as arguments to helper classes that built in exception handling but it's one of those things that is intuitive and I'd like to submit it for criticism, insight, or advice.
I would like to note up front that this is NOT how I do all of my exception handling, but there are ca...
We all know that using Exception Handling to control your program's logical flow is bad. That is, you would never do:
public void someMethod(Object someObject) {
try {
someObject.doSomething();
} catch (NullPointerException npe) {
//handle Null case
}
}
over
public void someMethod(Object someObject) {
...
Say I have nested methods a, b, c, d, e on each level we return errors in the normal course of operations, but e could also throw an exception (e.g. out of memory on STL insert). The exceptions are very seldom and how fast/slow actual unwinding is happening is not an issue.
What is the most appropriate strategy for exception handling i...
According to the .NET Framework General Reference: Error Raising and Handling Guidelines exceptions should not be thrown during 'normal' operations. Is invalid user input to a web form, say the user enters a duplicate name, considered normal? !! IMPORTANT !!: I'm sure we pretty much all have an opinion on this, please include a reference...
I want to implement some friendlier error messages if the user tries to run a python script which tries to import modules that have not been installed. This includes printing out instructions on how to install the missing module.
One way to do this would be to put a try..catch block around the imports, but this is a bit ugly since it wo...
I would like to test some exception handling logic in the empty catch block of the below code.
try
{
//Do Some stuff that throws a exception
//This is the code i need
}
catch (Exception)
{
//Handle things that inherits from Exception
}
catch
{
//Handle things that dont inherits from Exception
//Want to test this code
}
...
I've moved IOError handling to a separate function to avoid boilerplate when opening files for reading.
But what if IOError fires when the file is being read? If sshfs disconnects, or file is deleted by root, etc.?
def safe_open(*args):
try:
return open(*args)
except IOError:
quit('Error when opening file \'{0}\...
I believe that in properly coded systems - errors (as errors or exceptions) should not be possible (with the exception of a DB/memcached server going down causing a query to fail). Our code should not rely on any assumptions to properly work and should be as bullet proof as possible.
However, in order to insure that our systems handle ...