Tips using Fault Contract
When we are using Fault Contracts, We would be having in the Catch block as
catch (Exception ex)
{
MySampleFault fault = new MySampleFault();
fault.Reason = "Error Message is " + ex.Message.ToString();
throw new FaultException< MySampleFault >(fault);
}
But at the throw, an error is displayed "The creator of this fault did not specify a reason".
On checking various options, the error goes only when you rewrite it as
throw new FaultException< MySampleFault >(fault, new FaultReason(ex.Message.ToString()));
Cheers!!!
catch (Exception ex)
{
MySampleFault fault = new MySampleFault();
fault.Reason = "Error Message is " + ex.Message.ToString();
throw new FaultException< MySampleFault >(fault);
}
But at the throw, an error is displayed "The creator of this fault did not specify a reason".
On checking various options, the error goes only when you rewrite it as
throw new FaultException< MySampleFault >(fault, new FaultReason(ex.Message.ToString()));
Cheers!!!
Comments