internal static void RenderError(OwaContext owaContext, TextWriter writer, string message, string messageDetails, OwaEventHandlerErrorCode errorCode, Exception exception) { if (owaContext == null) { throw new ArgumentNullException("owaContext"); } owaContext.HttpContext.Response.Clear(); OwaEventHttpHandler.RenderErrorDiv(owaContext, writer, message, messageDetails, errorCode, exception); if (owaContext.CustomErrorInfo != null) { writer.Write("<div id=divCstInfo"); foreach (KeyValuePair <string, string> keyValuePair in owaContext.CustomErrorInfo) { writer.Write(" "); writer.Write(keyValuePair.Key); writer.Write("="); writer.Write("\""); writer.Write(Utilities.HtmlEncode(keyValuePair.Value)); writer.Write("\""); } writer.Write("></div>"); owaContext.CustomErrorInfo = null; } owaContext.HttpContext.Response.ContentType = Utilities.GetContentTypeString(OwaEventContentType.Html); owaContext.HttpContext.Response.Headers.Remove("X-OWA-EventResult"); owaContext.HttpContext.Response.AppendHeader("X-OWA-EventResult", "1"); }
public void EndUseNotificationPipe(IAsyncResult async) { if (this.isDisposing) { return; } OwaAsyncResult owaAsyncResult = (OwaAsyncResult)async; if (HttpContext.Current != null && OwaContext.Current != base.OwaContext) { base.OwaContext.IgnoreUnlockForcefully = true; } try { if (owaAsyncResult.Exception != null) { bool isBasicAuthentication = Utilities.IsBasicAuthentication(base.OwaContext.HttpContext.Request); ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(owaAsyncResult.Exception, base.OwaContext.MailboxIdentity, Utilities.IsWebPartRequest(base.OwaContext), string.Empty, string.Empty, isBasicAuthentication); Exception ex = (owaAsyncResult.Exception.InnerException == null) ? owaAsyncResult.Exception : owaAsyncResult.Exception.InnerException; ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "An exception was thrown during the processing of the async request"); StringBuilder stringBuilder = new StringBuilder(); using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { OwaEventHttpHandler.RenderErrorDiv(base.OwaContext, stringWriter, exceptionHandlingInformation.Message, exceptionHandlingInformation.MessageDetails, exceptionHandlingInformation.OwaEventHandlerErrorCode, exceptionHandlingInformation.HideDebugInformation ? null : ex); } if (this.response != null) { this.response.WriteError(Utilities.JavascriptEncode(stringBuilder.ToString())); base.OwaContext.ErrorSent = true; } } if (this.response != null) { this.response.WriteLastChunk(); } } catch (OwaNotificationPipeWriteException) { } finally { if (owaAsyncResult.Exception != null) { Utilities.HandleException(base.OwaContext, owaAsyncResult.Exception); } } }