public void Constructor_InvalidOperationException_TypeIsInvalidOperationException() { var exception = new InvalidOperationException("Invalid"); var sentryException = new SentryException(exception); Assert.That(sentryException.Type, Is.EqualTo("System.InvalidOperationException")); }
/// <summary> /// Initializes a new instance of the <see cref="JsonPacket"/> class. /// </summary> /// <param name="project">The project.</param> /// <param name="exception">The <see cref="Exception"/>.</param> public JsonPacket(string project, Exception exception) : this(project) { if (exception == null) throw new ArgumentNullException("exception"); Message = exception.Message; if (exception.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((exception.TargetSite.ReflectedType == null) ? "<dynamic type>" : exception.TargetSite.ReflectedType.FullName), exception.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Exceptions = new List<SentryException>(); for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException) { Module = currentException.Source, Type = currentException.GetType().Name, Value = currentException.Message }; Exceptions.Add(sentryException); } }
public void Constructor_DivideByZeroException_StackTraceIsNotNull() { var exception = TestHelper.GetException(); var sentryException = new SentryException(exception); Assert.That(sentryException.Stacktrace, Is.Not.Null); }
public void Constructor_DivideByZeroException_ModuleEqualsUnitTests() { var exception = TestHelper.GetException(); var sentryException = new SentryException(exception); Assert.That(sentryException.Module, Is.EqualTo("SharpRaven.UnitTests")); }
public JsonPacket(string project, Exception e) { Initialize(); Message = e.Message; if (e.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((e.TargetSite.ReflectedType == null) ? "<dynamic type>" : e.TargetSite.ReflectedType.FullName), e.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Project = project; ServerName = System.Environment.MachineName; Level = ErrorLevel.error; Exception = new SentryException(e); Exception.Module = e.Source; Exception.Type = e.GetType().Name; Exception.Value = e.Message; StackTrace = new SentryStacktrace(e); if (StackTrace.Frames.Count == 0) { StackTrace = null; } }
public JsonPacket(string project, Exception e) { Initialize(); Message = e.Message; if (e.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((e.TargetSite.ReflectedType == null) ? "<dynamic type>" : e.TargetSite.ReflectedType.FullName), e.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Project = project; ServerName = System.Environment.MachineName; Level = ErrorLevel.error; Exceptions = new List<SentryException>(); for (Exception currentException = e; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException); sentryException.Module = currentException.Source; sentryException.Type = currentException.GetType().Name; sentryException.Value = currentException.Message; Exceptions.Add(sentryException); } }
public void Constructor_InvalidOperationException_ValueIsEqualToMessage() { const string message = "Invalid"; var exception = new InvalidOperationException(message); var sentryException = new SentryException(exception); Assert.That(sentryException.Value, Is.EqualTo(message)); }
public void Constructor_NullException_DoesNotThrow() { var sentryException = new SentryException(null); Assert.That(sentryException.Type, Is.Null); Assert.That(sentryException.Value, Is.Null); Assert.That(sentryException.Module, Is.Null); Assert.That(sentryException.Stacktrace, Is.Null); }
private void Write(SentryException exception) { writer.WritePropertyName("sentry.interfaces.Exception"); writer.WriteStartObject(); { Write("type", exception.Type); Write("value", exception.Message); Write("module", exception.Module); } writer.WriteEndObject(); }
/// <summary> /// Initializes a new instance of the <see cref="JsonPacket"/> class. /// </summary> /// <param name="project">The project.</param> /// <param name="exception">The <see cref="Exception"/>.</param> public JsonPacket(string project, Exception exception) : this(project) { if (exception == null) { throw new ArgumentNullException("exception"); } Message = exception.Message; if (exception.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((exception.TargetSite.ReflectedType == null) ? "<dynamic type>" : exception.TargetSite.ReflectedType.FullName), exception.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Exceptions = new List <SentryException>(); for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException) { Module = currentException.Source, Type = currentException.GetType().Name, Value = currentException.Message }; Exceptions.Add(sentryException); } // ReflectionTypeLoadException doesn't contain much useful info in itself, and needs special handling ReflectionTypeLoadException reflectionTypeLoadException = exception as ReflectionTypeLoadException; if (reflectionTypeLoadException != null) { foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions) { SentryException sentryException = new SentryException(loaderException); Exceptions.Add(sentryException); } } }
public JsonPacket(string project, string log, string stack, LogType logType) { Initialize(); Message = log; Project = project; ServerName = System.Environment.MachineName; Level = ErrorLevel.error; Exception = new SentryException(log, stack, logType); Exception.Module = log; Exception.Type = logType.ToString(); Exception.Value = stack; StackTrace = null; }
public JsonPacket(string project, string log, string stack, LogType logType) { Initialize(); Message = log; Project = project; ServerName = System.Environment.MachineName; Level = ErrorLevel.error; Exception = new SentryException(log, stack, logType); Exception.Module = log; Exception.Type = logType.ToString(); Exception.Value = stack; StackTrace = null; }
/// <summary> /// Initializes a new instance of the <see cref="JsonPacket"/> class. /// </summary> /// <param name="project">The project.</param> /// <param name="exception">The <see cref="Exception"/>.</param> public JsonPacket(string project, Exception exception) : this(project) { if (exception == null) throw new ArgumentNullException("exception"); Message = exception.Message; if (exception.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((exception.TargetSite.ReflectedType == null) ? "<dynamic type>" : exception.TargetSite.ReflectedType.FullName), exception.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Exceptions = new List<SentryException>(); for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException) { Module = currentException.Source, Type = currentException.GetType().Name, Value = currentException.Message }; Exceptions.Add(sentryException); } // ReflectionTypeLoadException doesn't contain much useful info in itself, and needs special handling ReflectionTypeLoadException reflectionTypeLoadException = exception as ReflectionTypeLoadException; if (reflectionTypeLoadException != null) { foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions) { SentryException sentryException = new SentryException(loaderException); Exceptions.Add(sentryException); } } }
private void Initialize(Exception exception) { Message = exception.Message; //if (exception.TargetSite != null) //{ // // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. // Culprit = String.Format("{0} in {1}", // ((exception.TargetSite.ReflectedType == null) // ? "<dynamic type>" // : exception.TargetSite.ReflectedType.FullName), // exception.TargetSite.Name); // // ReSharper restore ConditionIsAlwaysTrueOrFalse //} Exceptions = new List <SentryException>(); for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException) { Module = currentException.Source, Type = currentException.GetType().Name, Value = currentException.Message }; Exceptions.Add(sentryException); } // ReflectionTypeLoadException doesn't contain much useful info in itself, and needs special handling ReflectionTypeLoadException reflectionTypeLoadException = exception as ReflectionTypeLoadException; if (reflectionTypeLoadException != null) { foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions) { SentryException sentryException = new SentryException(loaderException); Exceptions.Add(sentryException); } } }
public JsonPacket(string project, Exception e) { Initialize(); Message = e.Message; if (e.TargetSite != null) { Culprit = String.Format("{0}.{1}", e.TargetSite.ReflectedType.FullName, e.TargetSite.Name); } Project = project; ServerName = System.Environment.MachineName; Exception = new SentryException(e); Exception.Module = e.Source; Exception.Value = e.Message; StackTrace = new SentryStacktrace(e); }
public JsonPacket(string project, Exception e) { Initialize(); Message = e.Message; if (e.TargetSite != null) { Culprit = String.Format("{0}.{1}", e.TargetSite.ReflectedType.FullName, e.TargetSite.Name); } Project = project; ServerName = System.Environment.MachineName; Exception = new SentryException(e); Exception.Module = e.Source; Exception.Value = e.Message; StackTrace = new SentryStacktrace(e); }
public JsonPacket(string project, Exception e) { Initialize(); Message = e.Message; if (e.TargetSite != null) { Culprit = String.Format("{0}.{1}", e.TargetSite.ReflectedType.FullName, e.TargetSite.Name); } Project = project; Level = ErrorLevel.error; Exception = new SentryException(e); Exception.Module = e.Source; Exception.Type = e.GetType().Name; Exception.Value = e.Message; this.StackTrace = new SentryStacktrace(e); }
/// <summary> /// Initializes a new instance of the <see cref="JsonPacket"/> class. /// </summary> /// <param name="project">The project.</param> /// <param name="exception">The <see cref="Exception"/>.</param> public JsonPacket(string project, Exception exception) : this(project) { if (exception == null) { throw new ArgumentNullException("exception"); } Message = exception.Message; if (exception.TargetSite != null) { // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types. Culprit = String.Format("{0} in {1}", ((exception.TargetSite.ReflectedType == null) ? "<dynamic type>" : exception.TargetSite.ReflectedType.FullName), exception.TargetSite.Name); // ReSharper restore ConditionIsAlwaysTrueOrFalse } Exceptions = new List <SentryException>(); for (Exception currentException = exception; currentException != null; currentException = currentException.InnerException) { SentryException sentryException = new SentryException(currentException) { Module = currentException.Source, Type = currentException.GetType().Name, Value = currentException.Message }; Exceptions.Add(sentryException); } }
public void ToString_StringIsEqualTo_ExceptionToString() { var exception = TestHelper.GetException(); var sentryException = new SentryException(exception); string exceptionString = exception.ToString(); string stacktraceString = sentryException.ToString(); Console.WriteLine(exceptionString); Console.WriteLine(); Console.WriteLine(stacktraceString); Assert.That(stacktraceString, Is.EqualTo(exceptionString)); }
public void Constructor_PrivateException_TypeIsPrivateException() { var exception = new PrivateException(); var sentryException = new SentryException(exception); Assert.That(sentryException.Type, Is.EqualTo("SharpRaven.UnitTests.Data.PrivateException")); }