Class TestErrorController
- Namespace
- SEBT.Portal.Api.Controllers.Diagnostics
- Assembly
- SEBT.Portal.Api.dll
Diagnostic endpoints for validating OTEL tracing, structured logging, and error-handling behavior.
All endpoints are gated by the test_error_endpoints_enabled feature flag (off by default).
Enable in appsettings.Development.json or AWS AppConfig for dev/staging. Do not enable in production.
[ApiController]
[Route("api/test-error")]
[AllowAnonymous]
[FeatureGate(new string[] { "test_error_endpoints_enabled" })]
[Tags(new string[] { "Diagnostics" })]
public class TestErrorController : ControllerBase
- Inheritance
-
objectControllerBaseTestErrorController
Methods
HttpStatus(int)
Returns the specified HTTP status code without going through a command handler. Useful for testing frontend error-handling branches in isolation.
[HttpGet("http/{statusCode:int}")]
[ProducesResponseType(200)]
public IActionResult HttpStatus(int statusCode)
Parameters
statusCodeint
Returns
- IActionResult
SimulateSmartyHttpError(IAddressVerificationDiagnostics, CancellationToken)
Exercises the Smarty address verification error path for a server-error HTTP response.
IAddressVerificationDiagnostics runs the real verification service against a
canned 500 response, so its LogError and DependencyFailed result are
exercised without any network activity.
[HttpGet("dependencies/smarty/http-error")]
[ProducesResponseType(202)]
public Task<IActionResult> SimulateSmartyHttpError(IAddressVerificationDiagnostics diagnostics, CancellationToken cancellationToken)
Parameters
diagnosticsIAddressVerificationDiagnosticscancellationTokenCancellationToken
Returns
- Task<IActionResult>
SimulateSmartyTransportFailure(IAddressVerificationDiagnostics, CancellationToken)
Exercises the Smarty address verification error path for a transport-level failure
(e.g. firewall block, DNS failure). IAddressVerificationDiagnostics simulates
an System.Net.Http.HttpRequestException, which the verification service catches and logs
at Error.
[HttpGet("dependencies/smarty/transport-failure")]
[ProducesResponseType(202)]
public Task<IActionResult> SimulateSmartyTransportFailure(IAddressVerificationDiagnostics diagnostics, CancellationToken cancellationToken)
Parameters
diagnosticsIAddressVerificationDiagnosticscancellationTokenCancellationToken
Returns
- Task<IActionResult>
SimulateTimeout(ICommandHandler<TestErrorCommand>)
Simulates a timeout: TestErrorCommandHandler delays 30 seconds; the controller cancels after 500 ms. Validates that System.OperationCanceledException propagates correctly through OTEL spans and structured logging.
[HttpGet("exception/timeout")]
[ProducesResponseType(500)]
public Task<IActionResult> SimulateTimeout(ICommandHandler<TestErrorCommand> handler)
Parameters
handlerICommandHandler<TestErrorCommand>
Returns
- Task<IActionResult>
ThrowException(ICommandHandler<TestErrorCommand>, CancellationToken)
Throws an unhandled System.InvalidOperationException inside TestErrorCommandHandler. Validates that OTEL spans are marked faulted and the exception is captured in structured logs.
[HttpGet("exception")]
[ProducesResponseType(500)]
public Task<IActionResult> ThrowException(ICommandHandler<TestErrorCommand> handler, CancellationToken cancellationToken)
Parameters
handlerICommandHandler<TestErrorCommand>cancellationTokenCancellationToken
Returns
- Task<IActionResult>