private void logEnd(string sessionId, HttpRequest request, AnyResult result, Exception error) { var log = _log; var sb = new StringBuilder(1024); sb.Append($"{result.trackingId} >> "); if (error == null) { sb.Append(result.ToWireJson()); log.Trace(sb.ToString()); return; } var details = new { errorMessage = error.Message, sessionId, error.StackTrace, result, request = request.Dump(), }; sb.Append(details.ToJson()); log.Trace(sb.ToString()); }
private AnyResult newResult(string sessionId) { var result = new AnyResult { trackingId = AnyResultHelpers.GenerateTrackingId(sessionId), status = HttpStatusCode.OK }; return(result); }
private void setErrorDetails(AnyResult result, Exception error, bool detailsOnError) { if (error == null) { return; } result.status = HttpStatusCode.InternalServerError; result.error = new AnyResult.Error { message = $"Something went wrong ({result.trackingId})", }; if (detailsOnError == false) { return; } result.error.message += $"; {error.Message}"; result.error.details = error.Data; }
public static string ToJson(this AnyResult result) { return (JsonConvert.SerializeObject(result, Formatting.Indented, _jsonSettings)); }
public static string ToWireJson(this AnyResult result) { return (JsonConvert.SerializeObject(result, Formatting.None, _jsonSettings)); }
private void logStart(string sessionId, HttpRequest request, AnyResult result) { var log = _log; log.Trace($"{result.trackingId} << {request.RawUrl}"); }