This commit is contained in:
pizzaboxer 2024-10-26 23:51:31 +01:00
commit 643a1f0db2
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -16,6 +16,8 @@ namespace Bloxstrap.UI.Elements.Dialogs
/// </summary>
public partial class ExceptionDialog
{
const int MAX_GITHUB_URL_LENGTH = 8192;
public ExceptionDialog(Exception exception)
{
InitializeComponent();
@ -27,12 +29,19 @@ namespace Bloxstrap.UI.Elements.Dialogs
string repoUrl = $"https://github.com/{App.ProjectRepository}";
string wikiUrl = $"{repoUrl}/wiki";
string issueUrl = String.Format(
"{0}/issues/new?template=bug_report.yaml&title={1}&log={2}",
repoUrl,
HttpUtility.UrlEncode($"[BUG] {exception.GetType()}: {exception.Message}"),
HttpUtility.UrlEncode(String.Join('\n', App.Logger.History))
);
string title = HttpUtility.UrlEncode($"[BUG] {exception.GetType()}: {exception.Message}");
string log = HttpUtility.UrlEncode(String.Join('\n', App.Logger.History));
string issueUrl = $"{repoUrl}/issues/new?template=bug_report.yaml&title={title}&log={log}";
if (issueUrl.Length > MAX_GITHUB_URL_LENGTH)
{
// url is way too long for github. remove the log parameter.
issueUrl = $"{repoUrl}/issues/new?template=bug_report.yaml&title={title}";
if (issueUrl.Length > MAX_GITHUB_URL_LENGTH)
issueUrl = $"{repoUrl}/issues/new?template=bug_report.yaml"; // bruh
}
string helpMessage = String.Format(Strings.Dialog_Exception_Info_2, wikiUrl, issueUrl);