exception

How do I fix: InvalidOperationException upon Session timeout in Ajax WebService call

Hi All, We are invoking Asp.Net ajax web service from the client side. So the JavaScript functions have calls like: // The function to alter the server side state object and set the selected node for the case tree. function JSMethod(caseId, url) { Sample.XYZ.Method(param1, param2, OnMethodReturn); } function OnMethodReturn(re...

System.ArgumentException illegal characters in path

I am using Path.Combine, and one of the strings contain a Unicode characters. I get {System.ArgumentException} exception; illegal characters in path. According to MSDN filepath/name can have unicode characters. Why do I get this exception? Edit: Here is the code: Path.Combine("C:\PDM\Silver","Amabel Bender QQQ") ...

Does it make sense to catch exceptions in the main(...) ?

Hi, I found some code in a project which looks like that : int main(int argc, char *argv[]) { // some stuff try { theApp.Run(); } catch (std::exception& exc) { cerr << exc.what() << std::endl; exit(EXIT_FAILURE); } return (EXIT_SUCCESS); } I don't understand why the exceptions are being catched. If they weren't, the app...

Throwing ArgumentNullException

Suppose I have a method that takes an object of some kind as an argument. Now say that if this method is passed a null argument, it's a fatal error and an exception should be thrown. Is it worth it for me to code something like this (keeping in mind this is a trivial example): void someMethod(SomeClass x) { if (x == null){ ...

Java: using a RuntimeException to escape from a Visitor

I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way to handle this problem. The idea is that I want to cut short the recursive exploration of sub-trees by a visitor without having to check a "stop" flag in eve...

Rhino Mocks Exception Expect #1 Actual #0 : Need help

I've have searched on this and it seems to be a catch all, unfortunately everything I've read doesn't help figure it out. Here is the class: public interface IMockInterface { MockClass MockedMethod(); MockClass MockThis(); } public class MockClass : IMockInterface { public virtual MockClass MockedMethod() { MockClass r...

Checking C# new() initialisation for null?

I've found this piece of code on Koders: private ServiceProvider SiteServiceProvider { get { if (serviceProvider == null) { serviceProvider = new ServiceProvider(site as VSOLE.IServiceProvider); Debug.Assert(serviceProvider != null, "Unable to get ServiceProvider from site object."); ...

Exception Handling in C#: Multple Try/Catches vs. One

Is it good practice to have more than one try{} catch{} statement per method? ...

Automated Exception Handling

I was wondering if something exists (in Java world) able to take an snapshot of the JVM current state with the following features: Do it while an exception is being thrown. Capture local variables, method's arguments, etc. Put it in a handy file which can be used to extract or reproduce in a IDE the situation in your source code. The...

Question about distinguishing between a truly exceptional circumstances and a routine bad condition

A lot of developers say only throw exceptions in truly exceptional circumstances. One of these would be if an external hard drive I want to write to is not switched on (therefore not a connected/registered drive). However, there are some situations which are difficult to work out whether they are truly exceptional or not. For example, e...

sqlite3:Unable to close due to unfinalised statements

I have two sqlite connections and execute like below(CMyDatabase is a derived class of sqlite3): CMyDatabase* dbConnection1 = new CMyDatabase; dbConnection1->OpenDataBase(CQCommon::GetModulePath() + L"test.db"); CMyDatabase* dbConnection2 = new CMyDatabase; dbConnection2->OpenDataBase(CQCommon::GetModulePath() + L"test.db"); dbConnect...

Are there any good OSS instances of converting an Exception to HTML (C#) ?

Working with EntLib 4.1 and want the Exception block to send an email with error information. All that is fine but out of the box I have either the Text or Xml formatter to work with. I would love an Html representation that which brings in other information such as browser, http headers etc. Years ago I wrote one but dont have the sourc...

c# and xml-rpc.net: mismatch exception

I'm using xml-rpc.net to access an e-commerce site (php) from an c# application. The code: String[] fooResourcesReturn = FoobarProxy.resources(fooLoginReturn); returns the following XmlRpcTypeMismatchException: response contains struct value where string expected (as type String) [response : array mapped to type String[] : element 0]...

How do I get ruby to print a full backtrace instead of a truncated one?

When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me: tmp.rb:7:in `t': undefined method `bar' for nil:NilClass (NoMethodError) from tmp.rb:10:in `s' from tmp.rb:13:in `r' from tmp.rb:16:in `q' from ...

Intermittent ClassCastException from ElementNSImpl to own type during unmarshalling

We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions sometimes when trying to iterate over a list of unmarshalled objects. The important bit is sometimes, after a reboot the particular code works fine. This seems to point in the direction of concurrency/timing/race condition. I can confirm t...

Problem sub-classing BaseException in Python

I wanted to create my own Python exception class, like this: class MyException(BaseException): def __init__(self, errno, address): if errno == 10048: mess = str(address) + ' is already in use' else: mess = 'Unable to open ' + str(address) BaseException.__init__(mess) but when the pro...

In WCF - In the "Faulted" Event - How Do I Get The Exception Details?

I have a WCF server and I'm tapping into the "Faulted" event which stupidly only gives me "object sender, EventArgs e". How can I get the current 'Exception' object in that event? Or, if there is some sort of global system way, like Environment.GetCurrentException(), that would be awesome, but I can't find it. EDIT: To help explain wha...

How do you stop a PHP class from executing?

I'm looking for something like break for loops. Here's some example code (using Symfony's lime) where stop() would not let the class continue and I_DONT_WANT_THIS_TO_RUN() would not be executed. $browser->isStatusCode(200) ->isRequestParameter('module', 'home') ->isRequestParameter('action', 'index') ->click('Register') ->stop(...

IndexOutOfRangeException for an IList<T>

I am implementing a list, and I am wondering about the definition of the IndexOutOfRange. Which one of the following do you think is better? /// <exception cref="IndexOutOfRangeException">if index is less than 0 /// or greater than <see cref="Count"/> public T this[int index] { get { return myArray[index]; } } Or /// <exception cref=...

How can I intercept uncaught exceptions on Tomcat?

I am trying to figure out a clean way to intercept uncaught exceptions that occur in my application. I have log4j configured for logging the normal application flow and caught exceptions, so that is taken care of. Right now, I have a class that takes all error-level messages and adds them to a queue to be emailed in batches. Ideally,...