views:

154

answers:

2

Hi folks,

is it possible to throw a custom error message to a ThrowActivity, in windows workflow foundation?

eg. Imagine i want to throw this exception, in my WF :-

CutomException("This is my custom error message", myNumber, myObect);

cheers :)

+3  A: 

Maybe I do not understand your question well, but you can set the specific exception with the Fault property of ThrowActivity in any place before the activity execution, e.g.:

throwActivity1.Fault = new CustomException("This is my custom error message", myNumber, myObect);
Panos
Yep! Perfect! i couldn't figure out how to do that in the designer .. so i did it in the code behind .. works great. Checking the designer again, it still makes no sence :P but that's ok :)
Pure.Krome
+1  A: 

You can throw any custom exception like this way.

public DiscontinuedProductException discontinuedProductException1 = new DiscontinuedProductException();

[SerializableAttribute()] public class DiscontinuedProductException : Exception { public DiscontinuedProductException() : base() { }

    public DiscontinuedProductException(string message)
        : base(message)
    {
    }

    public DiscontinuedProductException(string message, Exception innerException)
        : base(message, innerException)
    {
    }

    protected DiscontinuedProductException(SerializationInfo info, StreamingContext context)
        : base(info, context)
    {
    }
}
balaweblog