@@ -60,12 +60,14 @@ public class StackifyError : ApplicationException
6060
6161
6262 public StackifyError ( long errorOccurredEpochMillis , ErrorItem errorItem )
63+ : this ( errorItem . Message , null )
6364 {
6465 OccurredEpochMillis = errorOccurredEpochMillis ;
6566 this . Error = errorItem ;
6667 }
6768
6869 public StackifyError ( DateTime errorOccurredUtc , ErrorItem errorItem )
70+ : this ( errorItem . Message , null )
6971 {
7072 TimeSpan ts = errorOccurredUtc . Subtract ( new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , 0 ) ) ;
7173 OccurredEpochMillis = ( long ) ts . TotalMilliseconds ;
@@ -79,24 +81,28 @@ public StackifyError(Exception exception)
7981 }
8082
8183 public StackifyError ( string message , Exception exception )
84+ : base ( message )
8285 {
8386 Init ( ) ;
8487
85- //Reflection caused error. Real error is the inner exception
86- if ( exception is TargetInvocationException && exception . InnerException != null )
88+ if ( exception != null )
8789 {
88- Error = new ErrorItem ( exception . InnerException ) ;
89- _Exception = exception . InnerException ;
90- }
91- else if ( exception is HttpUnhandledException && exception . InnerException != null )
92- {
93- Error = new ErrorItem ( exception . GetBaseException ( ) ) ;
94- _Exception = exception . GetBaseException ( ) ;
95- }
96- else
97- {
98- Error = new ErrorItem ( exception ) ;
99- _Exception = exception ;
90+ //Reflection caused error. Real error is the inner exception
91+ if ( exception is TargetInvocationException && exception . InnerException != null )
92+ {
93+ Error = new ErrorItem ( exception . InnerException ) ;
94+ _Exception = exception . InnerException ;
95+ }
96+ else if ( exception is HttpUnhandledException && exception . InnerException != null )
97+ {
98+ Error = new ErrorItem ( exception . GetBaseException ( ) ) ;
99+ _Exception = exception . GetBaseException ( ) ;
100+ }
101+ else
102+ {
103+ Error = new ErrorItem ( exception ) ;
104+ _Exception = exception ;
105+ }
100106 }
101107
102108 SetAdditionalMessage ( message ) ;
@@ -155,16 +161,20 @@ private void Init()
155161
156162 public StackifyError SetAdditionalMessage ( string message )
157163 {
158- if ( ! String . IsNullOrEmpty ( Error . Message ) )
164+ if ( Error != null )
159165 {
160- if ( ! String . IsNullOrEmpty ( message ) && ! Error . Message . Equals ( message , StringComparison . InvariantCultureIgnoreCase ) )
166+ if ( ! String . IsNullOrEmpty ( Error . Message ) )
161167 {
162- Error . Message = Error . Message + " (" + message + ")" ;
168+ if ( ! String . IsNullOrEmpty ( message ) &&
169+ ! Error . Message . Equals ( message , StringComparison . InvariantCultureIgnoreCase ) )
170+ {
171+ Error . Message = Error . Message + " (" + message + ")" ;
172+ }
173+ }
174+ else
175+ {
176+ Error . Message = message ;
163177 }
164- }
165- else
166- {
167- Error . Message = message ;
168178 }
169179
170180 return this ;
0 commit comments