mock data for web expection

Posted by Nvskhan under ASP.NET MVC on 5/6/2014 | Points: 10 | Views : 698 | Status : [Member] | Replies : 0
hi,

i need to create a mock data for below web exception. please help me how to create a mock data for web exception.

public override async Task GetDataAsync()
{
try
{
//do something
}
catch (WebException we)
{
HttpStatusCode hsc = ((HttpWebResponse)we.Response).StatusCode;
// If 500 Internal Server Error (because of timeout)
if (we.Status == WebExceptionStatus.Timeout)
{
}
// If 500 Internal Server Error (not because of timeout)
else if (hsc == HttpStatusCode.InternalServerError)
{
}
// If 503 Service Unavailable (usually because of high server load)
else if (hsc == HttpStatusCode.ServiceUnavailable)
{
}
// If 400 Bad Request
else if (hsc == HttpStatusCode.BadRequest)
{
}
// If 401 Unauthorized (missing or invalid "Authorization" HTTP Header)
else if (hsc == HttpStatusCode.Unauthorized)
{
}
// If 404 Not Found
else if (hsc == HttpStatusCode.NotFound)
{
}
// If 405 Method Not Allowed (wrong HTTP Verb)
else if (hsc == HttpStatusCode.MethodNotAllowed)
{
}
//exceptions.Add(we);
throw;
}




Responses

(No response found.)

Login to post response