The backend is as above in Api project. The client angular network tab, response is plain error message.
If the API call handle the error message, the Angular UI does catch the UserFriendlyException message, say the angular show the message in a toaster or display direct on a UI element. However, at the same time, the Generic Internal Error exception window also shows up. I don't want the second one, or the second one should be message in UserFriendlyException
Actually I tried UserFriendlyException, BusinessException, Exception, from backend Swagger, the error code is 400, the response content is plain text error message, instead of JSON format. I have this code below in HttpApi.Host module file:
if (env.IsDevelopment())
{
//app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseAbpExceptionHandling();
app.UseRouting();
Another interesting thing is, I use this code below in a controller method:
return StatusCode(400, new
{
error = new
{
message = "Your user-friendly message in json",
details = (string?)null,
code = (string?)null
}
});
The angular side doesn't display the message neither
ABP 8 MicroService architect, when backend throw an UserFriendlyException, the message not showing in Angular client, instead an Internal error message is shown
ABP framework 9, the customize Login page can remove self registration link, how to disable this feature so that swagger API also has no this API (api/account/register)
Another approach that worth a try is using Aspire.Net. Here is AI's answer: Never use it, but it seems worth a try.
.How to Use Aspire for Integration Testing: Add the Testing Package: Include the Aspire.Hosting.Testing NuGet package in your test project. Create a Test Host: Use DistributedApplicationFactory<TProgram> to create a factory that can launch your Aspire app host for testing. Configure the Test Environment: Define any necessary environment variables or containerized resources required for your tests within the DistributedApplicationFactory setup. Interact with Services: Obtain HttpClient instances or other client proxies from the DistributedApplicationFactory to interact with your services under test. Write Assertions: Implement test assertions to verify the expected behavior and interactions between your microservices. Clean Up Resources: Ensure proper disposal of the DistributedApplicationFactory to clean up resources after tests complete.
Thank you very much. I will try the Docker solution for SQL server. ABP's integration testing bootstrap is simple to use. However, for Micro Service architect, if an app service directly call another Micro service's API, then it would have problem when set up integration testing.
We don't want user navigate to register page, when create user via App admin page, user can login without registration.
Since our EF core Mapping use some syntax not supporting SqlLite, we need to mock each repository / app service when write test code for an AppService. However, while doing this way, AppService's Logger is null and throw exception for all places using it in the AppService. I guess any place using CurrentUser, CurrentTenant, CurrentUnitOfWork would also throw null reference exception