Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- catch (Exception ex)
- {
- Exception originalException = ex;
- while (ex != null)
- {
- WebException wex = ex as WebException;
- if (wex != null)
- {
- Console.WriteLine(wex.GetType() + " : " + wex.Message);
- if (wex.Response != null)
- {
- using (var stream = wex.Response.GetResponseStream())
- {
- using (var reader = new StreamReader(stream))
- {
- Console.WriteLine(reader.ReadToEnd());
- }
- }
- }
- Console.WriteLine(wex.StackTrace);
- throw;
- }
- ContentstackException cex = ex as ContentstackException;
- if (cex != null)
- {
- Console.WriteLine(cex.GetType() + " : " + cex.Message);
- Console.WriteLine("Error code: " + cex.ErrorCode);
- Console.WriteLine("Error message: " + cex.ErrorMessage);
- Console.WriteLine("Status code: " + cex.StatusCode);
- foreach (string key in cex.Errors.Keys)
- {
- Console.WriteLine("Error : " + key + " : " + cex.Errors[key]);
- }
- Console.WriteLine(cex.StackTrace);
- throw;
- }
- ex = ex.InnerException;
- }
- Console.WriteLine(originalException.GetType() + " : " + originalException.Message);
- Console.WriteLine(originalException.StackTrace);
- throw;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement