public void Process(Exception ex1) { var ex = ex1.GetMostInnerException(); if (ex is BusinessException) { if (ex is BusinessHttpResponseException) { throw new HttpResponseException(new HttpResponseMessage((ex as BusinessHttpResponseException).StatusCode) { Content = new OneAppStringContent((ex as BusinessHttpResponseException).ErrorResponse), ReasonPhrase = "Business Error" }); } else { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new OneAppStringContent(new ErrorResponse((ex as BusinessException).Message)), ReasonPhrase = "Business Error" }); } } //Log Critical errors LogsManager.Error(ex); string message = OneAppConfigurationKeys.ShowException ? ex.Message : "An error occurred, please try again or contact the administrator."; throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new OneAppStringContent(new ErrorResponse(message)), ReasonPhrase = "Unexpect Error" }); }
public void Send(string to, string subject, string body, bool isBodyHtml) { try { using (var msg = new MailMessage(_EmailFrom, to)) { msg.Subject = subject; msg.Body = body; msg.IsBodyHtml = isBodyHtml; SmtpClient smtpClient = new SmtpClient(_SMPTHosValue, _SMPTPortValue); smtpClient.EnableSsl = true; smtpClient.Timeout = 120000; smtpClient.UseDefaultCredentials = false; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Credentials = new System.Net.NetworkCredential(_EmailFrom, _EmailFromDecodedPasswordValue); smtpClient.Send(msg); } } catch (SmtpException ex) { if (ex.HResult == -2146233088) { LogsManager.Error(ex); throw new BusinessException("Operation timed out, please try again"); } throw; } }