adrianm
adrianm

Reputation: 14736

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?

Upvotes: 0

Views: 883

Answers (4)

marc_s
marc_s

Reputation: 755207

The CommunicationException is the base exception for all WCF exceptions. If you catch that, you catch everything WCF related.

See the MSDN docs for CommunicationException. It will also nicely show a list of all derived classes, e.g. all more specific exceptions that can occur in WCF - quite a long list!

Upvotes: 0

Kamran Khan
Kamran Khan

Reputation: 9986

Just thinking outloud... one solution could be:

  1. Add the list of exceptions(and exception casting) in your Custom exception class; for instance CException.
  2. As soon as you catch an exception in your Exception block, throw another exception into your CException class. For instance like following:

    catch(Exception ex){throw new CException("An error occured", ex);}

See this example.

Upvotes: 0

Henric
Henric

Reputation: 1410

This might be a good place to start: Expected Exceptions.

Upvotes: 2

John Saunders
John Saunders

Reputation: 161821

Why would there be a complete list? This isn't Java.

Why do you want to catch an exception you don't understand? How would you "handle" it if you don't know what it means?

Go ahead and catch exceptions to log them, if you like, but you should rethrow after you catch it. Let the exception propagate up to some code that knows what to do with it.

Upvotes: 1

Related Questions