I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException.
What's the best way to determine whether MyCustomException somehow caused the exc...
I recently had to develop an additional module for an existing service developed by a colleague. He had placed a try/catch block in the main working function for catching all unhadled exceptions that bubbled up to this level, logging them together with stack trace info etc:
try
{
// do main work
}
catch(Exception ex)
{
// log ex...
This question provides more clarity on the problem described here. I did some more investigation and found that the stack unwinding is not happening in the following piece of code:
class One
{
public:
int x ;
};
class Wrapper
{
public:
Wrapper(CString csText):mcsText(csText)
{
CString csTempText;
csTempText.Format...
I want to transfer all unhandled exceptions to an error page in Asp.Net MVC. What is the way to handle the unhandled exceptions in Asp.net MVC? Is there anything like application_error?
...
In two different application, one a custom the other the sample MVC application you get with a new VS2008 MVC project, [HandleError] is not catching exceptions.
In the sample application I have:
[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP....
I'd like to have something like a "catch-all" for exceptions thrown from a inside a Control or a Form that reside within the current thread, but without resorting to using the Application.ThreadException of the entire thread.
Why? Because I'd like to keep the exception handling modular.
All the code that can cause the problems is being...
I am trying to write a unit test to cover code found in our "last chance exception handler".
When referring to last chance exception handling I am talking about event handlers of the events:
Application.ThreadException
AppDomain.CurrentDomain.UnhandledException
More or less I am verifying that logs are being produced detailing the inf...
So, we are using the Enterprise Library 4.1 Exception Handling Application Block to deal with logging/handling our exceptions in a multiple-project application. We have a few custom exceptions and are throwing some exceptions whose classes are defined in the .NET framework's standard class libraries (e.g. ArgumentException, InvalidOperat...
Is it acceptable to do this? First try to the add the entity. If the add fails, it doesn't matter because that means the entity already exists?
Or is there a more elegant/easy solution?
EntityFrameworkEntities dal = EntityDataModelHelper.GetEntityDataModel();
try
{
dal.AddToXXXXXX(xxxxxxx);
}
catch
{
}
try
{
dal.SaveChange...
I know about unittest Python module.
I know about assertRaises() method of TestCase class.
I would like to write a test that succeeds when an exception is not raised.
Any hints please?
...
const int MIN_NUMBER = 4;
class Temp
{
public:
Temp(int x) : X(x)
{
}
bool getX() const
{
try
{
if( X < MIN_NUMBER)
{
//By mistake throwing any specific exception was missed out
//Program terminated here
throw ;
}
}
catch (bool bTemp)
{
cout<<"cat...
I'm trying to write some code that catches a particular exception and throw a more useful one for something higher up the call stack to deal with but also catch more general exceptions and handle them.
The code is something like this:
try
{
// Do stuff
}
catch (SomeException e)
{
throw new SomeExceptionWithContextInfo();
}
catc...
I've encountered a strange difference between a program running in VS2005 and running the executable directly. Essentially, when an exception is thrown in a method inside an Application.DoEvents() call, the exception can be caught when running inside Visual Studio. When running the compiled executable, the exception is not caught and t...
I have a grasp on this application block with ASP.NET, but I feel unsure if I am coding with it properly in ASP.NET.
I've looked all over for proper examples of how to use the Enterprise Library Exception Handling Application Block, but only turn up articles for Windows Forms.
Could somebody please point me in the right direction for u...
I'm just starting to use the Enterprise Library Exception Handling block.
It seems a little cumbersome.
Do I really have to do
try
{
//Do something with a DirectoryInfo object
}
catch(DirectoryNotFoundException ex)
{
bool rethrow = ExceptionPolicy.Handle(ex, _exceptionPolicyName);
if(rethrow)
throw;
}
Eve...
I work on a fairly complex Open Source project (opensimulator.org). It's currently sitting around 300 KLOC of C#, and there are a number of places where code has built up to trap and ignore exceptions, which end up disguising subtle bugs.
I'm wondering what tools are out there that can produce reports of overly general exception catchin...
I've dealt with instances where I would throw/rethrow an exception knowing that the code surrounding it would catch the specific exception. But is there any time you would want to throw an exception, knowing that it wouldn't be caught?
Or at least, NOT catch an exception?
Exceptions immediately halt the application unless their handle...
Basically, I've got a situation where one thread throws an exception which a different thread needs to handle. I'm trying to do this with boost exception, however somewhere along the line the exception loses its type and thus isn't caught by the catch blocks.
Basically, thread B wants to do something, however for various reasons it mus...
In my current project I see a lot of this type of code:
public User GetUserByName(string userName)
{
try
{
// Lots of code here to check if the user is in the cache,
// get it from the DB if not, set properties on it, etc...
}
catch (Exception ex)
{
throw new Exception("Exception getting user...
I'm using a PyQt4 user interface. I've redirected stderr to a log file for easy debugging and trouble-shooting, but now I need to display error messages to the user when an error occurs.
My issue is that I need to catch an exception when it happens and let the user know that it happened, but still let the traceback propagate to stderr ...