Skip to content

Commit

Permalink
pr feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
xenolightning committed Jun 4, 2024
1 parent a7940e0 commit 0074dec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -28,8 +28,10 @@ public virtual void SetSendCallback(SendHandler sendHandler)
protected virtual async Task ProcessOfflineCrashReports()
{
if (SendCallback is null)
{
return;

}

try
{
var cachedCrashReports = await GetAll(CancellationToken.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ private async void SendOfflineErrors(object state)

public void Start()
{
// This sets the timer to trigger once at the interval, and then "never again".
// This inherently prevents the timer from being re-entrant
_backgroundTimer.Change(Interval, TimeSpan.FromMilliseconds(int.MaxValue));
}

Expand Down
13 changes: 4 additions & 9 deletions Mindscape.Raygun4Net.NetCore.Common/RaygunClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,7 @@ protected async Task<string> OnCustomGroupingKey(Exception exception, RaygunMess

protected bool ValidateApiKey()
{
return ValidateApiKey(_settings.ApiKey);
}

private bool ValidateApiKey(string apiKey)
{
if (string.IsNullOrEmpty(apiKey))
if (string.IsNullOrEmpty(_settings.ApiKey))
{
Debug.WriteLine("ApiKey has not been provided, exception will not be logged");
return false;
Expand Down Expand Up @@ -449,8 +444,7 @@ protected virtual async Task StripAndSend(Exception exception, IList<string> tag

protected virtual IEnumerable<Exception> StripWrapperExceptions(Exception exception)
{
if (exception != null && _wrapperExceptions.Any(wrapperException =>
exception.GetType() == wrapperException && exception.InnerException != null))
if (exception != null && _wrapperExceptions.Any(wrapperException => exception.GetType() == wrapperException && exception.InnerException != null))
{
var aggregate = exception as AggregateException;

Expand Down Expand Up @@ -546,7 +540,8 @@ private async Task SendPayloadAsync(string payload, string apiKey, bool useOffli
Debug.WriteLine($"Error Logging Exception to Raygun: {ex.Message}");

// If we got no response or an unexpected server error then add it to offline storage to send later
// we get no response if the send call fails for any other reason (network etc)
// we get no response if the send call fails for any other reason (network etc.)
// checking that response.StatusCode >= 500, is an efficient check for any server errors
var shouldStoreMessage = response is null || response.StatusCode >= HttpStatusCode.InternalServerError;

if (useOfflineStore && shouldStoreMessage)
Expand Down
11 changes: 5 additions & 6 deletions Mindscape.Raygun4Net.NetCore/RaygunClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Net.Http;
using Mindscape.Raygun4Net.Storage;

namespace Mindscape.Raygun4Net;

Expand All @@ -10,31 +9,31 @@ public class RaygunClient : RaygunClientBase
public RaygunClient(string apiKey) : base(new RaygunSettings { ApiKey = apiKey })
{
}

[Obsolete("Use the RaygunClient(RaygunSettings, HttpClient) constructor instead")]
public RaygunClient(string apiKey, HttpClient httpClient) : base(new RaygunSettings { ApiKey = apiKey }, httpClient)
{
}

// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable SuggestBaseTypeForParameterInConstructor
// ReSharper disable UnusedMember.Global
public RaygunClient(RaygunSettings settings) : base(settings)
{
}

public RaygunClient(RaygunSettings settings, HttpClient httpClient) : base(settings, httpClient)
{
}

public RaygunClient(RaygunSettings settings, IRaygunUserProvider userProvider) : base(settings, userProvider)
{
}

public RaygunClient(RaygunSettings settings, HttpClient httpClient, IRaygunUserProvider userProvider) : base(settings, httpClient, userProvider)
{
}

// ReSharper restore MemberCanBeProtected.Global
// ReSharper restore SuggestBaseTypeForParameterInConstructor
// ReSharper restore UnusedMember.Global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
Expand All @@ -21,11 +20,11 @@ public LocalApplicationDataCrashReportStore(IBackgroundSendStrategy backgroundSe

private static string GetLocalAppDirectory(string directoryName)
{
directoryName ??= CreateUniqueDirectory();
directoryName ??= CreateUniqueDirectoryName();
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), directoryName);
}

private static string CreateUniqueDirectory()
private static string CreateUniqueDirectoryName()
{
// Try to generate a unique id, from the executable location
var uniqueId = Assembly.GetEntryAssembly()?.Location ?? throw new ApplicationException("Cannot determine unique application id");
Expand Down

0 comments on commit 0074dec

Please sign in to comment.