I am using WCF REST Starter Kit Preview 2 and i have problem with catching exceptions in client side.
I am using
HttpClient.EnsureStatusIsSuccessful()
method to catch my
new WebProtocolException(HttpStatusCode.InternalServerError, "Hello World!");
in the client.
And since when an InternalServerError happens an ArgumentOutOfRangeE...
I have a bunch of procedures that need to be executed successively until either they are all executed, or a certain condition is met. Here's the basic code that needs to be executed until a condition is met:
public boolean search()
{
robot.go();
robot.spin();
//etc - around 8 more similar commands (each takes around 2 seco...
I frequently want to add useful information to the message of an exception. Since the Message property of the Exception class does not have a public setter one option is to wrap the exception raised in another.
//...
catch(Exception e)
{
throw new Exception("Some useful information.", e);
}
Is this bad practise and if so what is the ...
I have function which takes a bitmap, copies part of it and saves it as 8bpp tiff. Filename of the result image is unique and file doesn't exist, program has permission to write to the target folder.
void CropImage(Bitmap map) {
Bitmap croped = new Bitmap(200, 50);
using (Graphics g = Graphics.FromImage(croped)) {
...
I created a simple console application using C#. It creates an instance of a class and calls one of the class' methods. This method contains a try-catch block to catch exceptions of the type System.Net.WebException and rethrow it so that the main method can catch it and act appropriately. When I execute the compiled application the excep...
I did something stupid and double clicked a db instead of the copy i made for read only testing. My app was running pulling data from remote servers for about 1.5 hrs. An exception occurred and it was because i opened the db which prevented the app from writing to it. If my code was more complete i wouldnt care and i would resume but its...
To test that something throws for example an ArgumentException I can do this:
Assert.Throws<ArgumentException>(() => dog.BarkAt(deafDog));
How can I check that the ParamName is correct in a clear way? And bonus question: Or would you perhaps perhaps recommend not testing this at all?
...
Say we have a method that looks like this:
public IEnumerable<Dog> GrowAll(this IEnumerable<Puppy> puppies)
{
if(subjects == null)
throw new ArgumentNullException("subjects");
foreach(var puppy in puppies)
yield return puppy.Grow();
}
If I test that by doing this:
Puppy[] puppies = null;
Assert.Throws<Argumen...
When catching an exception in .net, you can have as many type-specific exception blocks as needed. But I usually try to have at least one "general" exception catch block. But is there a way to get the type of the "real" exception thrown that is caught by the generic exception handler, perhaps using reflection?
For example, if I have
C...
Hi,
I don't know why I'm getting the following exception when reading a mail with an attachment file from mail server:
Exception in thread "main" javax.mail.MessagingException: Missing start boundary
at javax.mail.internet.MimeMultipart.parsebm<MimeMultipart.java:872)
at javax.mail.internet.MimeMultipart.parse<MimeMult...
I'm having a little trouble organizing my error messages for two interacting classes. One object has states that are 'error-ish', where something went wrong, or happened unexpectedly, but the situation is still salvageable. I don't want to use exceptions, 1. because they only have a single string for the message, and 2. because I want to...
I have a c++ dll which I need to debug. Due to the circumstances in which I am using the dll, I am unable to debug it via the calling application.
So, I created a try -catch, where the catch writes the exception to a file.
The line which needs to be debugged involves imported classes from a 3rd party dll, so I have no way of knowing wh...
Let's say you have a function (X) that takes a single object and does some work with it. It can fail in some way:
function X(obj) throws SomeException
And I have a collection of these objects, and want to run X on all of them. So I wrap that up in its own function:
function Y(objs)
foreach obj in objs
X(obj)
end
end
What is...
Hi All,
Got this question in a interview..since its a design question i am posting here.
The interviewer asked me to write out questions on exception handling in a j2ee application.
the actual question is "if i ask u to design a exception handling mechanism for a j2ee application what would be the question you will ask me"
At that ti...
I've been updating an existing library to throw exceptions to help improve debugging by people using the library.
At first, I thought I'd define exceptions specific to each class, however it turns out most of those exceptions are simply extensions of existing runtime exceptions (e.g., FooNegativeIntArgumentException extends IllegalArgum...
I want to make an error on purpose so that it would go into the "except":
How do i do that?
...
In the following method, FreeMem(), throws an EAccessViolation. What are the possible reasons?
procedure TCustomDataset.FreeRecordBuffer(var Buffer: PChar);
begin
FreeMem(Buffer);
end;
EDIT:
As far as I understand TDataset Buffers are only allocated in:
function TCustomDataset.AllocRecordBuffer: PChar;
begin
Result := AllocMem(...
Background: I'm doing COM programming of National Instruments' TestStand in Python. TestStand complains if objects aren't "released" properly (it pops up an "objects not released properly" debug dialog box). The way to release the TestStand COM objects in Python is to ensure all variables no longer contain the object—e.g. del() them, or ...
I am getting this exception:
Collection was modified; enumeration operation may not execute.
when executing this section of code:
List<T> results = new List<T>();
foreach (T item in items)
if (item.displayText.ToLower().Contains(searchText.ToLower()))
results.Add(item);
return results;
I can't see why I get this exce...
Hi,
What is the most useful strategy when your application throws an exception in the middle of the demo, in terms of keeping the client's mood still positive?
...