static void testWithoutStacktrace() { Console.WriteLine("Send exception without stacktrace."); var id = ravenClient.CaptureException(new Exception("Test without a stacktrace.")); Console.WriteLine("Sent packet: " + id); }
public async Task <ActionResult> Create(MapEntity model) { if (!ModelState.IsValid) { return(this.View(model)); } model.PartitionKey = MapEntity.MainKey; model.RowKey = ShortGuid.NewGuid().Value; try { // upload image to blob storage. model.ImageAddress = await UploadImageToStorage(model.RowKey, model.ImageAddress); await TableStorage.Insert(model); } catch (StorageException error) { Task.Run(() => RavenClient.CaptureException(error)); ViewBag.Alerts = new List <AlertModel> { new AlertModel(AlertType.Danger, error.Message) }; return(this.View(model)); } this.TempData["Alerts"] = AlertModel.CreateSingle(AlertType.Success, string.Format("{0} by {1} was created.", model.Title, model.Author)); this.TempData["Highlight"] = new HighlightModel(AlertType.Success, model.PartitionKey, model.RowKey); return(this.RedirectToAction("Index")); }
protected override void Append(LoggingEvent loggingEvent) { if (ravenClient == null) { ravenClient = new RavenClient(DSN) { Logger = Logger }; } var extra = GetExtra(); var tags = tagLayouts.ToDictionary(t => t.Name, t => (t.Layout.Format(loggingEvent) ?? "").ToString()); var exception = loggingEvent.ExceptionObject ?? loggingEvent.MessageObject as Exception; var level = Translate(loggingEvent.Level); if (exception != null) { ravenClient.CaptureException(exception, null, level, tags: tags, extra: extra); } else { var message = loggingEvent.RenderedMessage; if (message != null) { ravenClient.CaptureMessage(message, level, tags, extra); } } }
public async Task <ActionResult> Edit(string row, MapEntity model) { if (string.IsNullOrEmpty(model.FeaturedDate)) { ModelState.AddModelError("FeaturedDate", "A featured date is required."); } if (!ModelState.IsValid) { return(this.View(model)); } try { await TableStorage.Replace(model); } catch (StorageException error) { Task.Run(() => RavenClient.CaptureException(error)); return(this.AzureStorageErrorResponse(row, MapEntity.FeaturedKey, error)); } string alertMessage = string.Format("The featured map for {0} was updated.", model.FeaturedDate); this.TempData["Alerts"] = AlertModel.CreateSingle(AlertType.Success, alertMessage); this.TempData["Highlight"] = new HighlightModel(AlertType.Info, model.PartitionKey, model.RowKey); return(this.RedirectToAction("Index")); }
static void Main(string[] args) { Console.WriteLine("Initializing RavenClient."); RavenClient rc = new RavenClient("https://*****:*****@app.getsentry.com/3739"); PrintInfo("Sentry Uri: " + rc.CurrentDSN.SentryURI); PrintInfo("Port: " + rc.CurrentDSN.Port); PrintInfo("Public Key: " + rc.CurrentDSN.PublicKey); PrintInfo("Private Key: " + rc.CurrentDSN.PrivateKey); PrintInfo("Project ID: " + rc.CurrentDSN.ProjectID); Console.WriteLine("Causing division by zero exception."); try { rc.CaptureMessage("About to try the amazingly silly act of dividing by 0..."); Program.PerformDivideByZero(); Console.WriteLine("Failed."); } catch (Exception e) { Console.WriteLine("Captured: " + e.Message); int id = rc.CaptureException(e); Console.WriteLine("Sent packet: " + id); } Console.ReadLine(); }
protected override void Append(LoggingEvent loggingEvent) { if (ravenClient == null) { ravenClient = new RavenClient(DSN) { Logger = Logger, // If something goes wrong when sending the event to Sentry, make sure this is written to log4net's internal // log. See <add key="log4net.Internal.Debug" value="true"/> ErrorOnCapture = ex => LogLog.Error(typeof(SentryAppender), "[" + Name + "] " + ex.Message, ex) }; } var httpExtra = HttpExtra.GetHttpExtra(); object extra; if (httpExtra != null) { extra = new { Environment = new EnvironmentExtra(), Http = httpExtra }; } else { extra = new { Environment = new EnvironmentExtra() }; } var tags = tagLayouts.ToDictionary(t => t.Name, t => (t.Layout.Format(loggingEvent) ?? "").ToString()); var exception = loggingEvent.ExceptionObject ?? loggingEvent.MessageObject as Exception; var level = Translate(loggingEvent.Level); if (exception != null) { ravenClient.CaptureException(exception, null, level, tags: tags, extra: extra); } else { var message = loggingEvent.RenderedMessage; if (message != null) { ravenClient.CaptureMessage(message, level, tags, extra); } } }
public async Task <ActionResult> Delete(string row, MapEntity model) { MapEntity entity = await TableStorage.Get(MapEntity.MainKey, row); try { await TableStorage.Delete(entity); } catch (StorageException error) { Task.Run(() => RavenClient.CaptureException(error)); return(this.AzureStorageErrorResponse(row, MapEntity.MainKey, error)); } this.TempData["Alerts"] = AlertModel.CreateSingle(AlertType.Info, string.Format("{0} by {1} was deleted.", entity.Title, entity.Author)); return(this.RedirectToAction("Index")); }
public async Task <ActionResult> Create(MapEntity model) { if (string.IsNullOrEmpty(model.FeaturedDate)) { ModelState.AddModelError("FeaturedDate", "A featured date is required."); } if (!ModelState.IsValid) { return(this.View(model)); } model.PartitionKey = MapEntity.FeaturedKey; model.RowKey = ShortGuid.NewGuid().Value; try { await TableStorage.Insert(model); } catch (StorageException error) { Task.Run(() => RavenClient.CaptureException(error)); ViewBag.Alerts = new List <AlertModel> { new AlertModel(AlertType.Danger, error.Message) }; return(this.View(model)); } string alertMessage = string.Format("{0} by {1} for {2} was created.", model.Title, model.Author, model.FeaturedDate); this.TempData["Alerts"] = AlertModel.CreateSingle(AlertType.Success, alertMessage); this.TempData["Highlight"] = new HighlightModel(AlertType.Success, model.PartitionKey, model.RowKey); return(this.RedirectToAction("Index")); }
public async Task <ActionResult> Edit(string row, MapEntity model) { if (!ModelState.IsValid) { return(this.View(model)); } try { await TableStorage.Replace(model); } catch (StorageException error) { Task.Run(() => RavenClient.CaptureException(error)); return(this.AzureStorageErrorResponse(row, MapEntity.MainKey, error)); } this.TempData["Alerts"] = AlertModel.CreateSingle(AlertType.Success, string.Format("{0} by {1} was updated.", model.Title, model.Author)); this.TempData["Highlight"] = new HighlightModel(AlertType.Info, model.PartitionKey, model.RowKey); return(this.RedirectToAction("Index")); }
static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e) { ravenClient.CaptureException((Exception)e.ExceptionObject); }