You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I'm facing an issue where Angular HTTP error handling as suggested by ABP in https://docs.abp.io/en/abp/latest/UI/Angular/HTTP-Error-Handling does not catch UserFriendlyException thrown by .NET backend server.
Any help or advice would be appreciated, thanks!
Reproduction Steps
Throwing UserFriendlyException in C#, e.g. ProductStockInAppService
varproductStockIns=await _productStockInRepository.GetListAsync();if(productStockIns.Count <1){thrownew UserFriendlyException("There is nothing to export.");}
Catching the error in Angular using CustomHttpErrorHandlerService
I tested it again and the issue still persists with ABP v8.1.3. I have a simple BookAppService that throws the UserFriendlyException with message and a button in home component that calls the API.
You may try customizing the related part as follows:
// If this service is picked from ErrorHandler, this execute method will be called.
execute() {
const messageRegex = /"message":"(?<message>.*?)"/;
const messageMatch = this.error.error.match(messageRegex);
let message = 'Bad request!';
if (messageMatch && messageMatch.groups && messageMatch.groups.message) {
message = messageMatch.groups.message;
}
this.toaster.error(message, this.error.status.toString());
}
or you can directly use getErrorFromRequestBody function inside error utilities that might be even more suitable.
Is there an existing issue for this?
Description
Hi I'm facing an issue where Angular HTTP error handling as suggested by ABP in https://docs.abp.io/en/abp/latest/UI/Angular/HTTP-Error-Handling does not catch
UserFriendlyException
thrown by .NET backend server.Any help or advice would be appreciated, thanks!
Reproduction Steps
Throwing
UserFriendlyException
in C#, e.g.ProductStockInAppService
Catching the error in Angular using
CustomHttpErrorHandlerService
Toast the error message with status code
Expected behavior
Angular
CustomHttpErrorHandlerService
should be able to capture response body that's identical to what is produced by swagger UI:Actual behavior
error.error
is undefined when shown in log:ToasterService does not show error message, but with the correct status code:
Regression?
No response
Known Workarounds
No response
Version
8.1
User Interface
Angular
Database Provider
EF Core (Default)
Tiered or separate authentication server
Tiered
Operation System
Windows (Default)
Other information
I had also configured
AbpExceptionHandlingOptions
in ApplicationService module to send exception details to clients:ApplicationModule.cs
The text was updated successfully, but these errors were encountered: