Capture() public method

Captures the specified event.
public Capture ( SentryEvent @event ) : string
@event SharpRaven.Data.SentryEvent
return string
Exemplo n.º 1
0
 /// <summary>
 /// Handles the Click event of the btnSubmitError control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 /// <exception cref="Exception"></exception>
 protected void btnSubmitError_Click( object sender, EventArgs e )
 {
     try
     {
         throw new Exception( tbError.Text );
     }
     catch ( Exception ex )
     {
         var sentryDSN = GlobalAttributesCache.Read().GetValue( "SentryDSN" ) ?? string.Empty;
         var sentryClient = new RavenClient( sentryDSN );
         if ( !string.IsNullOrEmpty( sentryDSN ) && sentryClient != null )
         {
             sentryClient.Capture( new SentryEvent( ex ) );
             nbInformation.Visible = true;
         }
     }
 }
        public void LogException( Exception ex )
        {
            var personAlias = this.GetPersonAlias();
            Model.ExceptionLogService.LogException( ex, HttpContext.Current, null, null, personAlias );

            // send the event to Sentry if configured
            var sentryDSN = Web.Cache.GlobalAttributesCache.Read().GetValue( "SentryDSN" ) ?? string.Empty;
            var sentryClient = new RavenClient( sentryDSN );
            if ( !string.IsNullOrEmpty( sentryDSN ) && sentryClient != null )
            {
                //var exceptionLog = new ExceptionLog
                //{
                //    HasInnerException = ex.InnerException != null,
                //    ExceptionType = ex.GetType().ToString(),
                //    Description = ex.Message,
                //    Source = ex.Source,
                //    StackTrace = ex.StackTrace,
                //    CreatedByPersonAliasId = personAlias.Id,
                //    ModifiedByPersonAliasId = personAlias.Id,
                //    CreatedDateTime = RockDateTime.Now,
                //    ModifiedDateTime = RockDateTime.Now,
                //};

                //var context = HttpContext.Current;
                //if ( context != null && context.Request != null && context.Response != null )
                //{
                //    exceptionLog.StatusCode = context.Response.StatusCode.ToString();
                //    exceptionLog.PageUrl = context.Request.Url.ToString();
                //    exceptionLog.QueryString = context.Request.Url.Query;

                //    var formItems = context.Request.Form;
                //    if ( formItems.Keys.Count > 0 )
                //    {
                //        exceptionLog.Form = formItems.AllKeys.ToDictionary( k => k, k => formItems[k] ).ToString();
                //    }

                //    var serverVars = context.Request.ServerVariables;
                //    if ( serverVars.Keys.Count > 0 )
                //    {
                //        exceptionLog.ServerVariables = serverVars.AllKeys.ToDictionary( k => k, k => serverVars[k] ).ToString();
                //    }
                //}

                //ex.Data.Add( "context", exceptionLog );
                sentryClient.Capture( new SentryEvent( ex ) );
            }
        }