public StackingInfo(Error error, ErrorSignatureFactory errorSignatureFactory) { if (error == null) throw new ArgumentNullException("error"); ErrorInfo innerMostError = error.GetInnermostError(); Method defaultMethod = innerMostError.StackTrace != null ? innerMostError.StackTrace.FirstOrDefault() : null; if (defaultMethod == null && error.StackTrace != null) defaultMethod = error.StackTrace.FirstOrDefault(); Tuple<ErrorInfo, Method> st = error.GetStackingTarget(); // If we can't find the info, try doing a new signature to mark the target. if (st == null) { errorSignatureFactory.GetSignature(error); st = error.GetStackingTarget(); } Error = st != null ? st.Item1 ?? error : error.GetInnermostError(); Method = st != null ? st.Item2 : defaultMethod; if (error.Code == "404" && error.RequestInfo != null && !String.IsNullOrEmpty(error.RequestInfo.Path)) { Is404 = true; Path = error.RequestInfo.Path; } }
public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) { var errorRepository = new ErrorRepository(collection.Database, null, null, null); BsonValue id = document.GetDocumentId(); if (id == null || !id.IsObjectId) return; Error error = errorRepository.GetById(id.ToString()); if (error == null) return; if (document.Contains("sig")) document.Remove("sig"); var signatureFactory = new ErrorSignatureFactory(); // updates the document to set the IsSignatureTarget ErrorSignature signature = signatureFactory.GetSignature(error); errorRepository.Update(error); }
public AssignToStackAction(ErrorStackRepository stackRepository, ErrorSignatureFactory signatureFactory) { _stackRepository = stackRepository; _signatureFactory = signatureFactory; }