mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-01 05:13:40 +01:00
feat(feedback): optionally include last exception
This commit is contained in:
parent
689b8fa847
commit
ef16e346c6
3 changed files with 21 additions and 4 deletions
|
|
@ -22,7 +22,7 @@ namespace Dalamud.Support
|
|||
/// <param name="content">The content of the feedback.</param>
|
||||
/// <param name="reporter">The reporter name.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public static async Task SendFeedback(PluginManifest plugin, string content, string reporter)
|
||||
public static async Task SendFeedback(PluginManifest plugin, string content, string reporter, bool includeException)
|
||||
{
|
||||
if (content.IsNullOrWhitespace())
|
||||
return;
|
||||
|
|
@ -37,6 +37,9 @@ namespace Dalamud.Support
|
|||
Version = plugin.AssemblyVersion.ToString(),
|
||||
};
|
||||
|
||||
if (includeException)
|
||||
model.Exception = Troubleshooting.LastException?.ToString();
|
||||
|
||||
var postContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
|
||||
var response = await client.PostAsync(BugBaitUrl, postContent);
|
||||
|
||||
|
|
@ -56,6 +59,9 @@ namespace Dalamud.Support
|
|||
|
||||
[JsonProperty("reporter")]
|
||||
public string? Reporter { get; set; }
|
||||
|
||||
[JsonProperty("exception")]
|
||||
public string? Exception { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ namespace Dalamud.Support
|
|||
/// </summary>
|
||||
public static class Troubleshooting
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the most recent exception to occur.
|
||||
/// </summary>
|
||||
public static Exception? LastException { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Log the last exception in a parseable format to serilog.
|
||||
/// </summary>
|
||||
|
|
@ -26,6 +31,8 @@ namespace Dalamud.Support
|
|||
/// <param name="context">Additional context.</param>
|
||||
public static void LogException(Exception exception, string context)
|
||||
{
|
||||
LastException = exception;
|
||||
|
||||
try
|
||||
{
|
||||
var payload = new ExceptionPayload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue