public AppException(string message, HttpErrorCodes code, InternalErrorCodes internalCode) : base(message) { _code = code; _message = message; _internalCode = internalCode; }
private AsyncWriter WriteTopLevelContent( Stream stream, Action<XmlWriter> writeAtomAction, Action<JsonWriter> writeJsonAction, Func<object, string> invalidContentTypeErrorMessageFunction, InternalErrorCodes internalErrorCode) { Debug.Assert(this.writerPayloadKind != ODataPayloadKind.Unsupported, "Expected payload kind, format and encoding to be set by now."); AsyncBufferedStream asyncBufferedStream = new AsyncBufferedStream(stream); switch (this.format) { case ODataFormat.Json: StreamWriter textWriter = new StreamWriter(asyncBufferedStream, this.encoding); JsonWriter jsonWriter = new JsonWriter(textWriter, this.settings.Indent); writeJsonAction(jsonWriter); return new AsyncWriter(asyncBufferedStream, textWriter, jsonWriter); case ODataFormat.Atom: XmlWriter xmlWriter = ODataAtomWriterUtils.CreateXmlWriter(asyncBufferedStream, this.settings, this.encoding); writeAtomAction(xmlWriter); return new AsyncWriter(asyncBufferedStream, xmlWriter); case ODataFormat.Default: Debug.Assert(false, "Should never get here as content-type negotiation should not return Default format for top level content."); string contentType = this.message.GetHeader(ODataHttpHeaders.ContentType); throw new ODataException(invalidContentTypeErrorMessageFunction(contentType)); default: throw new ODataException(Strings.General_InternalError(internalErrorCode)); } }
private static void GetErrorCode(InternalErrorCodes tie, ref string errorMessage, ref EventLogEntryType severity) { #region long switch statement to assign strings and severitys switch (tie) { case InternalErrorCodes.CorruptConfiguration: errorMessage = "The configuration is corrupt. Initialisation has not successfully completed. {0}"; severity = EventLogEntryType.Error; break; case InternalErrorCodes.NoListenersWarning: errorMessage = "There are no listeners currently attached, Output will be lost. {0}"; severity = EventLogEntryType.Warning; break; case InternalErrorCodes.ListenerCountInformation: severity = EventLogEntryType.Information; break; case InternalErrorCodes.InitialisationError: errorMessage = "There was an error during Initialisation, it is likely that the configuration is not correctly applied. {0}"; severity = EventLogEntryType.Error; break; case InternalErrorCodes.AccessDeniedToSomething: errorMessage = "Access Was Denied, Unable to retrieve some infomration. {0}"; severity = EventLogEntryType.Warning; break; case InternalErrorCodes.OperatingSystemIncompatibility: errorMessage = "The operating system was incompatible with the requested operation. {0}"; severity = EventLogEntryType.Warning; break; case InternalErrorCodes.Diagnostics: errorMessage = "Diagnostic Log\r\n {0}"; severity = EventLogEntryType.Information; break; case InternalErrorCodes.TCPListenerError: errorMessage = "TCPListener Error: {0}"; severity = EventLogEntryType.Warning; break; case InternalErrorCodes.ODSListenerError: errorMessage = "Diagnostic Log\r\n {0}"; severity = EventLogEntryType.Error; break; case InternalErrorCodes.InitialisationContentCorrupt: errorMessage = "Initialisation Content\r\n {0}"; severity = EventLogEntryType.Information; break; default: errorMessage = "Unknown Error"; severity = EventLogEntryType.Error; break; } #endregion }
/// <summary> /// Called to report an error, this will attempt to notify /// the user of an error, by writing to the event log or screen /// </summary> /// <param name="tie">InternalError enum indicating the error</param> /// <param name="param">An Additional parameter to describe the error more fully.</param> /// <param name="overrideLevel">Allows you to override the severity</param> public static void LogInternalError(InternalErrorCodes tie, string param, TraceLevel overrideLevel) { if (internalTraceLevel == TraceLevel.Off) { return; } if (param == null) { throw new InvalidOperationException("ASSERTION: The parameter should be empty if its not specified"); } string errorMessage = string.Empty; EventLogEntryType severity = EventLogEntryType.Information; GetErrorCode(tie, ref errorMessage, ref severity); if (overrideLevel != TraceLevel.Off) { switch (overrideLevel) { case TraceLevel.Error: severity = EventLogEntryType.Error; break; case TraceLevel.Info: severity = EventLogEntryType.Information; break; case TraceLevel.Verbose: severity = EventLogEntryType.SuccessAudit; break; case TraceLevel.Warning: severity = EventLogEntryType.Warning; break; } } switch (internalTraceLevel) { case TraceLevel.Error: if ((severity == EventLogEntryType.Information) || (severity == EventLogEntryType.SuccessAudit) || (severity == EventLogEntryType.Warning)) { return; } break; case TraceLevel.Info: if (severity == EventLogEntryType.SuccessAudit) { return; } break; case TraceLevel.Warning: if ((severity == EventLogEntryType.Information) || (severity == EventLogEntryType.SuccessAudit)) { return; } break; default: break; } errorMessage = string.Format(errorMessage, param); WriteToEventLog(severity, errorMessage, (int)tie); }
public static void LogInternalError(InternalErrorCodes tie, string param, TraceLevel overrideLevel) { // Not Implemented. }
/// <summary> /// Called to report an error within Tex, this will attempt to notify /// the user of an error, by writing to the event log or screen /// </summary> /// <param name="tie">InternalErrorCodes enum indicating the error</param> /// <param name="param">An Additional parameter to describe the error more fully.</param> public static void LogInternalError(InternalErrorCodes tie, string param) { LogInternalError(tie, param, TraceLevel.Off); }