@@ -16,6 +16,9 @@ public static class ExceptionlessClientExtensions {
16
16
/// <param name="client">The ExceptionlessClient.</param>
17
17
/// <param name="apiKey">The API key that will be used when sending events to the server.</param>
18
18
public static void Startup ( this ExceptionlessClient client , string apiKey = null ) {
19
+ if ( client == null )
20
+ throw new ArgumentNullException ( nameof ( client ) ) ;
21
+
19
22
if ( ! String . IsNullOrEmpty ( apiKey ) )
20
23
client . Configuration . ApiKey = apiKey ;
21
24
@@ -45,6 +48,9 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
45
48
/// </summary>
46
49
/// <param name="client">The ExceptionlessClient.</param>
47
50
public static void Shutdown ( this ExceptionlessClient client ) {
51
+ if ( client == null )
52
+ throw new ArgumentNullException ( nameof ( client ) ) ;
53
+
48
54
#if ! PORTABLE && ! NETSTANDARD1_2
49
55
client . UnregisterAppDomainUnhandledExceptionHandler ( ) ;
50
56
client . UnregisterOnProcessExitHandler ( ) ;
@@ -64,6 +70,9 @@ public static void Shutdown(this ExceptionlessClient client) {
64
70
/// <param name="client">The client instance.</param>
65
71
/// <param name="exception">The unhandled exception.</param>
66
72
public static void SubmitUnhandledException ( this ExceptionlessClient client , Exception exception ) {
73
+ if ( client == null )
74
+ throw new ArgumentNullException ( nameof ( client ) ) ;
75
+
67
76
var builder = exception . ToExceptionless ( client : client ) ;
68
77
builder . PluginContextData . MarkAsUnhandledError ( ) ;
69
78
builder . Submit ( ) ;
@@ -75,6 +84,9 @@ public static void SubmitUnhandledException(this ExceptionlessClient client, Exc
75
84
/// <param name="client">The client instance.</param>
76
85
/// <param name="exception">The exception.</param>
77
86
public static void SubmitException ( this ExceptionlessClient client , Exception exception ) {
87
+ if ( client == null )
88
+ throw new ArgumentNullException ( nameof ( client ) ) ;
89
+
78
90
client . CreateException ( exception ) . Submit ( ) ;
79
91
}
80
92
@@ -84,6 +96,9 @@ public static void SubmitException(this ExceptionlessClient client, Exception ex
84
96
/// <param name="client">The client instance.</param>
85
97
/// <param name="exception">The exception.</param>
86
98
public static EventBuilder CreateException ( this ExceptionlessClient client , Exception exception ) {
99
+ if ( client == null )
100
+ throw new ArgumentNullException ( nameof ( client ) ) ;
101
+
87
102
return exception . ToExceptionless ( client : client ) ;
88
103
}
89
104
@@ -93,6 +108,9 @@ public static EventBuilder CreateException(this ExceptionlessClient client, Exce
93
108
/// <param name="client">The client instance.</param>
94
109
/// <param name="message">The log message.</param>
95
110
public static void SubmitLog ( this ExceptionlessClient client , string message ) {
111
+ if ( client == null )
112
+ throw new ArgumentNullException ( nameof ( client ) ) ;
113
+
96
114
client . CreateLog ( message ) . Submit ( ) ;
97
115
}
98
116
@@ -103,6 +121,9 @@ public static void SubmitLog(this ExceptionlessClient client, string message) {
103
121
/// <param name="source">The log source.</param>
104
122
/// <param name="message">The log message.</param>
105
123
public static void SubmitLog ( this ExceptionlessClient client , string source , string message ) {
124
+ if ( client == null )
125
+ throw new ArgumentNullException ( nameof ( client ) ) ;
126
+
106
127
client . CreateLog ( source , message ) . Submit ( ) ;
107
128
}
108
129
@@ -114,6 +135,9 @@ public static void SubmitLog(this ExceptionlessClient client, string source, str
114
135
/// <param name="message">The log message.</param>
115
136
/// <param name="level">The log level.</param>
116
137
public static void SubmitLog ( this ExceptionlessClient client , string source , string message , string level ) {
138
+ if ( client == null )
139
+ throw new ArgumentNullException ( nameof ( client ) ) ;
140
+
117
141
client . CreateLog ( source , message , level ) . Submit ( ) ;
118
142
}
119
143
@@ -125,6 +149,9 @@ public static void SubmitLog(this ExceptionlessClient client, string source, str
125
149
/// <param name="message">The log message.</param>
126
150
/// <param name="level">The log level.</param>
127
151
public static void SubmitLog ( this ExceptionlessClient client , string source , string message , LogLevel level ) {
152
+ if ( client == null )
153
+ throw new ArgumentNullException ( nameof ( client ) ) ;
154
+
128
155
client . CreateLog ( source , message , level . ToString ( ) ) . Submit ( ) ;
129
156
}
130
157
@@ -135,6 +162,9 @@ public static void SubmitLog(this ExceptionlessClient client, string source, str
135
162
/// <param name="message">The log message.</param>
136
163
/// <param name="level">The log level.</param>
137
164
public static void SubmitLog ( this ExceptionlessClient client , string message , LogLevel level ) {
165
+ if ( client == null )
166
+ throw new ArgumentNullException ( nameof ( client ) ) ;
167
+
138
168
client . CreateLog ( null , message , level . ToString ( ) ) . Submit ( ) ;
139
169
}
140
170
@@ -144,6 +174,9 @@ public static void SubmitLog(this ExceptionlessClient client, string message, Lo
144
174
/// <param name="client">The client instance.</param>
145
175
/// <param name="message">The log message.</param>
146
176
public static EventBuilder CreateLog ( this ExceptionlessClient client , string message ) {
177
+ if ( client == null )
178
+ throw new ArgumentNullException ( nameof ( client ) ) ;
179
+
147
180
return client . CreateEvent ( ) . SetType ( Event . KnownTypes . Log ) . SetMessage ( message ) ;
148
181
}
149
182
@@ -154,6 +187,9 @@ public static EventBuilder CreateLog(this ExceptionlessClient client, string mes
154
187
/// <param name="source">The log source.</param>
155
188
/// <param name="message">The log message.</param>
156
189
public static EventBuilder CreateLog ( this ExceptionlessClient client , string source , string message ) {
190
+ if ( client == null )
191
+ throw new ArgumentNullException ( nameof ( client ) ) ;
192
+
157
193
return client . CreateLog ( message ) . SetSource ( source ) ;
158
194
}
159
195
@@ -165,6 +201,9 @@ public static EventBuilder CreateLog(this ExceptionlessClient client, string sou
165
201
/// <param name="message">The log message.</param>
166
202
/// <param name="level">The log level.</param>
167
203
public static EventBuilder CreateLog ( this ExceptionlessClient client , string source , string message , string level ) {
204
+ if ( client == null )
205
+ throw new ArgumentNullException ( nameof ( client ) ) ;
206
+
168
207
var builder = client . CreateLog ( source , message ) ;
169
208
170
209
if ( ! String . IsNullOrWhiteSpace ( level ) )
@@ -181,6 +220,9 @@ public static EventBuilder CreateLog(this ExceptionlessClient client, string sou
181
220
/// <param name="message">The log message.</param>
182
221
/// <param name="level">The log level.</param>
183
222
public static EventBuilder CreateLog ( this ExceptionlessClient client , string source , string message , LogLevel level ) {
223
+ if ( client == null )
224
+ throw new ArgumentNullException ( nameof ( client ) ) ;
225
+
184
226
return CreateLog ( client , source , message , level . ToString ( ) ) ;
185
227
}
186
228
@@ -191,6 +233,9 @@ public static EventBuilder CreateLog(this ExceptionlessClient client, string sou
191
233
/// <param name="message">The log message.</param>
192
234
/// <param name="level">The log level.</param>
193
235
public static EventBuilder CreateLog ( this ExceptionlessClient client , string message , LogLevel level ) {
236
+ if ( client == null )
237
+ throw new ArgumentNullException ( nameof ( client ) ) ;
238
+
194
239
return CreateLog ( client , null , message , level . ToString ( ) ) ;
195
240
}
196
241
@@ -200,6 +245,9 @@ public static EventBuilder CreateLog(this ExceptionlessClient client, string mes
200
245
/// <param name="client">The client instance.</param>
201
246
/// <param name="feature">The name of the feature that was used.</param>
202
247
public static EventBuilder CreateFeatureUsage ( this ExceptionlessClient client , string feature ) {
248
+ if ( client == null )
249
+ throw new ArgumentNullException ( nameof ( client ) ) ;
250
+
203
251
return client . CreateEvent ( ) . SetType ( Event . KnownTypes . FeatureUsage ) . SetSource ( feature ) ;
204
252
}
205
253
@@ -209,6 +257,9 @@ public static EventBuilder CreateFeatureUsage(this ExceptionlessClient client, s
209
257
/// <param name="client">The client instance.</param>
210
258
/// <param name="feature">The name of the feature that was used.</param>
211
259
public static void SubmitFeatureUsage ( this ExceptionlessClient client , string feature ) {
260
+ if ( client == null )
261
+ throw new ArgumentNullException ( nameof ( client ) ) ;
262
+
212
263
client . CreateFeatureUsage ( feature ) . Submit ( ) ;
213
264
}
214
265
@@ -218,6 +269,9 @@ public static void SubmitFeatureUsage(this ExceptionlessClient client, string fe
218
269
/// <param name="client">The client instance.</param>
219
270
/// <param name="resource">The name of the resource that was not found.</param>
220
271
public static EventBuilder CreateNotFound ( this ExceptionlessClient client , string resource ) {
272
+ if ( client == null )
273
+ throw new ArgumentNullException ( nameof ( client ) ) ;
274
+
221
275
return client . CreateEvent ( ) . SetType ( Event . KnownTypes . NotFound ) . SetSource ( resource ) ;
222
276
}
223
277
@@ -227,6 +281,9 @@ public static EventBuilder CreateNotFound(this ExceptionlessClient client, strin
227
281
/// <param name="client">The client instance.</param>
228
282
/// <param name="resource">The name of the resource that was not found.</param>
229
283
public static void SubmitNotFound ( this ExceptionlessClient client , string resource ) {
284
+ if ( client == null )
285
+ throw new ArgumentNullException ( nameof ( client ) ) ;
286
+
230
287
client . CreateNotFound ( resource ) . Submit ( ) ;
231
288
}
232
289
@@ -235,6 +292,9 @@ public static void SubmitNotFound(this ExceptionlessClient client, string resour
235
292
/// </summary>
236
293
/// <param name="client">The client instance.</param>
237
294
public static EventBuilder CreateSessionStart ( this ExceptionlessClient client ) {
295
+ if ( client == null )
296
+ throw new ArgumentNullException ( nameof ( client ) ) ;
297
+
238
298
return client . CreateEvent ( ) . SetType ( Event . KnownTypes . Session ) ;
239
299
}
240
300
@@ -243,6 +303,9 @@ public static EventBuilder CreateSessionStart(this ExceptionlessClient client) {
243
303
/// </summary>
244
304
/// <param name="client">The client instance.</param>
245
305
public static void SubmitSessionStart ( this ExceptionlessClient client ) {
306
+ if ( client == null )
307
+ throw new ArgumentNullException ( nameof ( client ) ) ;
308
+
246
309
client . CreateSessionStart ( ) . Submit ( ) ;
247
310
}
248
311
@@ -252,6 +315,9 @@ public static void SubmitSessionStart(this ExceptionlessClient client) {
252
315
/// <param name="client">The client instance.</param>
253
316
/// <param name="sessionIdOrUserId">The session id or user id.</param>
254
317
public static void SubmitSessionEnd ( this ExceptionlessClient client , string sessionIdOrUserId = null ) {
318
+ if ( client == null )
319
+ throw new ArgumentNullException ( nameof ( client ) ) ;
320
+
255
321
sessionIdOrUserId = sessionIdOrUserId ?? client . Configuration . CurrentSessionIdentifier ;
256
322
if ( String . IsNullOrWhiteSpace ( sessionIdOrUserId ) )
257
323
return ;
@@ -266,6 +332,9 @@ public static void SubmitSessionEnd(this ExceptionlessClient client, string sess
266
332
/// <param name="client">The client instance.</param>
267
333
/// <param name="sessionIdOrUserId">The session id or user id.</param>
268
334
public static void SubmitSessionHeartbeat ( this ExceptionlessClient client , string sessionIdOrUserId = null ) {
335
+ if ( client == null )
336
+ throw new ArgumentNullException ( nameof ( client ) ) ;
337
+
269
338
sessionIdOrUserId = sessionIdOrUserId ?? client . Configuration . CurrentSessionIdentifier ;
270
339
if ( String . IsNullOrWhiteSpace ( sessionIdOrUserId ) )
271
340
return ;
@@ -283,6 +352,9 @@ public static class ExceptionlessClientExtensions {
283
352
#if ! PORTABLE && ! NETSTANDARD1_2
284
353
private static UnhandledExceptionEventHandler _onAppDomainUnhandledException ;
285
354
public static void RegisterAppDomainUnhandledExceptionHandler ( this ExceptionlessClient client ) {
355
+ if ( client == null )
356
+ throw new ArgumentNullException ( nameof ( client ) ) ;
357
+
286
358
if ( _onAppDomainUnhandledException == null ) {
287
359
_onAppDomainUnhandledException = ( sender , args ) => {
288
360
var exception = args . ExceptionObject as Exception ;
@@ -297,6 +369,9 @@ public static void RegisterAppDomainUnhandledExceptionHandler(this Exceptionless
297
369
298
370
// process queue immediately since the app is about to exit.
299
371
client . ProcessQueue ( ) ;
372
+
373
+ if ( client . Configuration . SessionsEnabled )
374
+ client . SubmitSessionEnd ( ) ;
300
375
} ;
301
376
}
302
377
@@ -309,6 +384,9 @@ public static void RegisterAppDomainUnhandledExceptionHandler(this Exceptionless
309
384
}
310
385
311
386
public static void UnregisterAppDomainUnhandledExceptionHandler ( this ExceptionlessClient client ) {
387
+ if ( client == null )
388
+ throw new ArgumentNullException ( nameof ( client ) ) ;
389
+
312
390
if ( _onAppDomainUnhandledException == null )
313
391
return ;
314
392
@@ -318,10 +396,15 @@ public static void UnregisterAppDomainUnhandledExceptionHandler(this Exceptionle
318
396
319
397
private static EventHandler _onProcessExit ;
320
398
public static void RegisterOnProcessExitHandler ( this ExceptionlessClient client ) {
399
+ if ( client == null )
400
+ throw new ArgumentNullException ( nameof ( client ) ) ;
401
+
321
402
if ( _onProcessExit == null ) {
322
403
_onProcessExit = ( sender , args ) => {
323
404
client . ProcessQueue ( ) ;
324
- client . SubmitSessionEnd ( ) ;
405
+
406
+ if ( client . Configuration . SessionsEnabled )
407
+ client . SubmitSessionEnd ( ) ;
325
408
} ;
326
409
}
327
410
@@ -334,6 +417,9 @@ public static void RegisterOnProcessExitHandler(this ExceptionlessClient client)
334
417
}
335
418
336
419
public static void UnregisterOnProcessExitHandler ( this ExceptionlessClient client ) {
420
+ if ( client == null )
421
+ throw new ArgumentNullException ( nameof ( client ) ) ;
422
+
337
423
if ( _onProcessExit == null )
338
424
return ;
339
425
0 commit comments