/// <summary> /// Initializes instance form local exception /// </summary> public WrappedExceptionData(Exception error, bool captureStack = true, bool captureExternalStatus = true) { error.NonNull(nameof(error)); var tp = error.GetType(); m_TypeName = tp.FullName; m_Message = error.Message; if (error is AzosException) { m_Code = ((AzosException)error).Code; } var app = ExecutionContext.Application; m_AppId = app.AppId; m_AppName = app.Name; m_Source = error.Source; if (captureStack) { m_StackTrace = error.StackTrace; } if (error.InnerException != null) { m_InnerException = new WrappedExceptionData(error.InnerException, captureStack, captureExternalStatus); } if (captureExternalStatus && error is IExternalStatusProvider esp) { m_ExternalStatus = esp.ProvideExternalStatus(captureStack); } }
/// <summary> /// Creates an instance of WrappedExceptionData saturating it from base64-encoded BSON data. /// This method complements .ToBase64() /// </summary> public static WrappedExceptionData FromBase64(string base64) { var bin = Convert.FromBase64String(base64); var doc = BSONDocument.FromArray(bin); var ser = new BSONSerializer(); var result = new WrappedExceptionData(); object ctx = null; result.DeserializeFromBSON(ser, doc, ref ctx); return(result); }
public void DeserializeFromBSON(BSONSerializer serializer, BSONDocument doc, ref object context) { var iv = doc["wrp"] as BSONDocumentElement; if (iv == null) { return; } m_Wrapped = new WrappedExceptionData(); serializer.Deserialize(iv.Value, m_Wrapped); }
public void DeserializeFromBSON(BSONSerializer serializer, BSONDocument doc, ref object context) { m_TypeName = doc.TryGetObjectValueOf("tname").AsString(); m_Message = doc.TryGetObjectValueOf("msg").AsString(); m_Code = doc.TryGetObjectValueOf("code").AsInt(); m_ApplicationName = doc.TryGetObjectValueOf("app").AsString(); m_Source = doc.TryGetObjectValueOf("src").AsString(); m_StackTrace = doc.TryGetObjectValueOf("trace").AsString(); m_WrappedData = doc.TryGetObjectValueOf("wdata").AsString(); var iv = doc["inner"] as BSONDocumentElement; if (iv == null) { return; } m_InnerException = new WrappedExceptionData(); serializer.Deserialize(iv.Value, m_InnerException); }
/// <summary> /// Initializes instance form local exception /// </summary> public WrappedExceptionData(Exception error, bool captureStack = true) { if (error == null) { throw new AzosException(StringConsts.ARGUMENT_ERROR + "WrappedExceptionData.ctor(error=null)"); } var tp = error.GetType(); m_TypeName = tp.FullName; m_Message = error.Message; if (error is AzosException) { m_Code = ((AzosException)error).Code; } m_ApplicationName = ExecutionContext.Application.Name; m_Source = error.Source; if (captureStack) { m_StackTrace = error.StackTrace; } if (error.InnerException != null) { m_InnerException = new WrappedExceptionData(error.InnerException); } var source = error as IWrappedExceptionDataSource; if (source != null) { m_WrappedData = source.GetWrappedData(); } }
void ITypeSerializationCore.Deserialize(TypedDoc aDoc, ReadingStreamer streamer) { var doc = (Azos.WrappedExceptionData)aDoc; while (true) { var name = Reader.ReadName(streamer); if (name == 0) { break; //EODoc } var dt = Reader.ReadDataType(streamer); DataType?atp = null; switch (name) { case 111520460468340: { // 'tpname' if (dt == DataType.Null) { doc.TypeName = null; } else if (dt == DataType.String) { doc.TypeName = Reader.ReadString(streamer); } else { break; } continue; } case 6779757: { // 'msg' if (dt == DataType.Null) { doc.Message = null; } else if (dt == DataType.String) { doc.Message = Reader.ReadString(streamer); } else { break; } continue; } case 1701080931: { // 'code' if (dt == DataType.Int32) { doc.Code = Reader.ReadInt32(streamer); } else { break; } continue; } case 6517363: { // 'src' if (dt == DataType.Null) { doc.Source = null; } else if (dt == DataType.String) { doc.Source = Reader.ReadString(streamer); } else { break; } continue; } case 111477511058547: { // 'strace' if (dt == DataType.Null) { doc.StackTrace = null; } else if (dt == DataType.String) { doc.StackTrace = Reader.ReadString(streamer); } else { break; } continue; } case 491328007785: { // 'inner' if (dt == DataType.Null) { doc.InnerException = null; continue; } if (dt != DataType.Doc) { break; } var vdoc = new Azos.WrappedExceptionData(); if (Reader.TryReadRow(doc, vdoc, streamer, CodeGenerator.GetName(name))) { doc.InnerException = vdoc; } continue; } } Reader.ConsumeUnmatched(doc, streamer, CodeGenerator.GetName(name), dt, atp); } }
void ITypeSerializationCore.Deserialize(TypedDoc aDoc, ReadingStreamer streamer) { var doc = (Azos.Log.Message)aDoc; while (true) { var name = Reader.ReadName(streamer); if (name == 0) { break; //EODoc } var dt = Reader.ReadDataType(streamer); DataType?atp = null; switch (name) { case 1684628583: { // 'gdid' if (dt == DataType.GDID) { doc.Gdid = Reader.ReadGDID(streamer); } else { break; } continue; } case 1684632935: { // 'guid' if (dt == DataType.Guid) { doc.Guid = Reader.ReadGuid(streamer); } else { break; } continue; } case 7103858: { // 'rel' if (dt == DataType.Guid) { doc.RelatedTo = Reader.ReadGuid(streamer); } else { break; } continue; } case 7368801: { // 'app' if (dt == DataType.Atom) { doc.App = Reader.ReadAtom(streamer); } else { break; } continue; } case 1819175011: { // 'chnl' if (dt == DataType.Atom) { doc.Channel = Reader.ReadAtom(streamer); } else { break; } continue; } case 28788: { // 'tp' if (dt != DataType.Int32) { break; } var ev = (@Azos.@Log.@MessageType)Reader.ReadInt32(streamer); doc.Type = ev; continue; } case 6517363: { // 'src' if (dt == DataType.Int32) { doc.Source = Reader.ReadInt32(streamer); } else { break; } continue; } case 6517877: { // 'utc' if (dt == DataType.DateTime) { doc.UTCTimeStamp = Reader.ReadDateTime(streamer); } else { break; } continue; } case 7631720: { // 'hst' if (dt == DataType.Null) { doc.Host = null; } else if (dt == DataType.String) { doc.Host = Reader.ReadString(streamer); } else { break; } continue; } case 7172710: { // 'frm' if (dt == DataType.Null) { doc.From = null; } else if (dt == DataType.String) { doc.From = Reader.ReadString(streamer); } else { break; } continue; } case 7368564: { // 'top' if (dt == DataType.Null) { doc.Topic = null; } else if (dt == DataType.String) { doc.Topic = Reader.ReadString(streamer); } else { break; } continue; } case 7633012: { // 'txt' if (dt == DataType.Null) { doc.Text = null; } else if (dt == DataType.String) { doc.Text = Reader.ReadString(streamer); } else { break; } continue; } case 7496048: { // 'par' if (dt == DataType.Null) { doc.Parameters = null; } else if (dt == DataType.String) { doc.Parameters = Reader.ReadString(streamer); } else { break; } continue; } case 6518885: { // 'exc' if (dt == DataType.Null) { doc.ExceptionData = null; continue; } if (dt != DataType.Doc) { break; } var vdoc = new Azos.WrappedExceptionData(); if (Reader.TryReadRow(doc, vdoc, streamer, CodeGenerator.GetName(name))) { doc.ExceptionData = vdoc; } continue; } case 495756862561: { // 'adims' if (dt == DataType.Null) { doc.ArchiveDimensions = null; } else if (dt == DataType.String) { doc.ArchiveDimensions = Reader.ReadString(streamer); } else { break; } continue; } } Reader.ConsumeUnmatched(doc, streamer, CodeGenerator.GetName(name), dt, atp); } }
public WrappedException(string message, WrappedExceptionData data) : base(message) { m_Wrapped = data; }
public WrappedException(WrappedExceptionData data) : base(data.Message) { m_Wrapped = data; }