Skip to content

Commit

Permalink
Recording exception details in logs to identify issues easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
edward.meng authored and ejsmith committed Mar 15, 2019
1 parent 90f5d81 commit c00d2ea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Exceptionless/ExceptionlessClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public bool UpdateUserEmailAndDescription(string referenceId, string email, stri
try {
var response = _submissionClient.Value.PostUserDescription(referenceId, new UserDescription(email, description), Configuration, Configuration.Resolver.GetJsonSerializer());
if (!response.Success)
_log.Value.FormattedError(typeof(ExceptionlessClient), "Failed to submit user email and description for event '{0}': {1} {2}", referenceId, response.StatusCode, response.Message);
_log.Value.FormattedError(typeof(ExceptionlessClient), response.Exception, "Failed to submit user email and description for event '{0}': {1} {2}", referenceId, response.StatusCode, response.Message);

return response.Success;
} catch (Exception ex) {
Expand Down
4 changes: 3 additions & 1 deletion src/Exceptionless/Queue/DefaultEventQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public Task Process() {
_log.Error(typeof(DefaultEventQueue), "Event submission discarded for being too large. The event will not be submitted.");
}
} else if (!response.Success) {
_log.Error(typeof(DefaultEventQueue), String.Concat("An error occurred while submitting events: ", response.Message));
_log.Error(typeof(DefaultEventQueue), response.Exception,
String.IsNullOrEmpty(response.Message) ? "An error occurred while submitting events." :
String.Concat("An error occurred while submitting events: ", response.Message));
SuspendProcessing();
deleteBatch = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptionless/Submission/DefaultSubmissionClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SubmissionResponse PostEvents(IEnumerable<Event> events, ExceptionlessCon
_client.Value.AddAuthorizationHeader(config.ApiKey);
response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
} catch (Exception ex) {
return new SubmissionResponse(500, message: ex.Message);
return new SubmissionResponse(500, exception: ex);
}

int settingsVersion;
Expand Down Expand Up @@ -71,7 +71,7 @@ public SubmissionResponse PostUserDescription(string referenceId, UserDescriptio
_client.Value.AddAuthorizationHeader(config.ApiKey);
response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
} catch (Exception ex) {
return new SubmissionResponse(500, message: ex.Message);
return new SubmissionResponse(500, exception: ex);
}

int settingsVersion;
Expand Down
5 changes: 4 additions & 1 deletion src/Exceptionless/Submission/SubmissionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Exceptionless.Submission {
public class SubmissionResponse {
public SubmissionResponse(int statusCode, string message = null) {
public SubmissionResponse(int statusCode, string message = null, Exception exception = null) {
StatusCode = statusCode;
Message = message;

Expand All @@ -14,6 +14,7 @@ public SubmissionResponse(int statusCode, string message = null) {
UnableToAuthenticate = (HttpStatusCode)statusCode == HttpStatusCode.Unauthorized || (HttpStatusCode)statusCode == HttpStatusCode.Forbidden;
NotFound = (HttpStatusCode)statusCode == HttpStatusCode.NotFound;
RequestEntityTooLarge = (HttpStatusCode)statusCode == HttpStatusCode.RequestEntityTooLarge;
Exception = exception;
}

public bool Success { get; private set; }
Expand All @@ -26,5 +27,7 @@ public SubmissionResponse(int statusCode, string message = null) {

public int StatusCode { get; private set; }
public string Message { get; private set; }

public Exception Exception { get; private set; }
}
}

0 comments on commit c00d2ea

Please sign in to comment.