[backend/asp] Add ExceptionVerbosity level Debug
This commit is contained in:
parent
f252c1a85e
commit
4af69a6afa
3 changed files with 28 additions and 18 deletions
|
@ -97,9 +97,9 @@ public class ErrorHandlerMiddleware(
|
||||||
StatusCode = ctx.Response.StatusCode,
|
StatusCode = ctx.Response.StatusCode,
|
||||||
Error = verbosity >= ExceptionVerbosity.Basic ? ce.Error : ce.StatusCode.ToString(),
|
Error = verbosity >= ExceptionVerbosity.Basic ? ce.Error : ce.StatusCode.ToString(),
|
||||||
Message = verbosity >= ExceptionVerbosity.Basic ? ce.Message : null,
|
Message = verbosity >= ExceptionVerbosity.Basic ? ce.Message : null,
|
||||||
Details = verbosity == ExceptionVerbosity.Full ? ce.Details : null,
|
Details = verbosity >= ExceptionVerbosity.Full ? ce.Details : null,
|
||||||
Errors = verbosity == ExceptionVerbosity.Full ? (ce as ValidationException)?.Errors : null,
|
Errors = verbosity >= ExceptionVerbosity.Full ? (ce as ValidationException)?.Errors : null,
|
||||||
Source = verbosity == ExceptionVerbosity.Full ? type : null,
|
Source = verbosity >= ExceptionVerbosity.Full ? type : null,
|
||||||
RequestId = ctx.TraceIdentifier
|
RequestId = ctx.TraceIdentifier
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class ErrorHandlerMiddleware(
|
||||||
StatusCode = 500,
|
StatusCode = 500,
|
||||||
Error = "Internal Server Error",
|
Error = "Internal Server Error",
|
||||||
Message = verbosity >= ExceptionVerbosity.Basic ? e.Message : null,
|
Message = verbosity >= ExceptionVerbosity.Basic ? e.Message : null,
|
||||||
Source = verbosity == ExceptionVerbosity.Full ? type : null,
|
Source = verbosity >= ExceptionVerbosity.Full ? type : null,
|
||||||
RequestId = ctx.TraceIdentifier
|
RequestId = ctx.TraceIdentifier
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -294,5 +294,6 @@ public enum ExceptionVerbosity
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
None = 0,
|
None = 0,
|
||||||
Basic = 1,
|
Basic = 1,
|
||||||
Full = 2
|
Full = 2,
|
||||||
|
Debug = 3,
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
@using Microsoft.Extensions.Options
|
@using Microsoft.Extensions.Options
|
||||||
@model ErrorPageModel
|
@model ErrorPageModel
|
||||||
@inject IOptions<Config.InstanceSection> Instance
|
@inject IOptions<Config.InstanceSection> Instance
|
||||||
|
@inject IOptions<Config.SecuritySection> Security
|
||||||
@{
|
@{
|
||||||
// Not meant for direct consumption, use with RazorViewRenderService.
|
// Not meant for direct consumption, use with RazorViewRenderService.
|
||||||
Layout = null;
|
Layout = null;
|
||||||
|
@ -41,7 +42,6 @@
|
||||||
}
|
}
|
||||||
@if (Model.Error.Errors is { Count: > 0 } errors)
|
@if (Model.Error.Errors is { Count: > 0 } errors)
|
||||||
{
|
{
|
||||||
<p>
|
|
||||||
@foreach (var error in errors)
|
@foreach (var error in errors)
|
||||||
{
|
{
|
||||||
<strong>@error.Key</strong>
|
<strong>@error.Key</strong>
|
||||||
|
@ -52,7 +52,6 @@
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
</p>
|
|
||||||
}
|
}
|
||||||
@if (Model.Error.Source != null)
|
@if (Model.Error.Source != null)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +64,12 @@
|
||||||
<strong>Request ID:</strong>
|
<strong>Request ID:</strong>
|
||||||
<code>@Model.Error.RequestId</code>
|
<code>@Model.Error.RequestId</code>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@if (Security.Value.ExceptionVerbosity >= ExceptionVerbosity.Debug)
|
||||||
|
{
|
||||||
|
<pre><code>@Model.Error.Exception.ToString()</code></pre>
|
||||||
|
}
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<strong>Iceshrimp.NET</strong> v@(Instance.Value.Version)
|
<strong>Iceshrimp.NET</strong> v@(Instance.Value.Version)
|
||||||
@if (Model.Error.Exception is PublicPreviewDisabledException)
|
@if (Model.Error.Exception is PublicPreviewDisabledException)
|
||||||
|
|
|
@ -43,7 +43,11 @@ AllowLocalIPv4 = false
|
||||||
AllowLocalIPv6 = false
|
AllowLocalIPv6 = false
|
||||||
|
|
||||||
;; The level of detail in API error responses
|
;; The level of detail in API error responses
|
||||||
;; Options: [None, Basic, Full]
|
;; Options: [None, Basic, Full, Verbose]
|
||||||
|
;; - 'None' only returns the request identifier & status code
|
||||||
|
;; - 'Basic' adds the error code & message
|
||||||
|
;; - 'Full' adds error details (if any) and the name of the class that caused the exception
|
||||||
|
;; - 'Debug' adds the stack trace (HTML only)
|
||||||
ExceptionVerbosity = Basic
|
ExceptionVerbosity = Basic
|
||||||
|
|
||||||
;; Whether to allow instance registrations
|
;; Whether to allow instance registrations
|
||||||
|
|
Loading…
Add table
Reference in a new issue