Open Closed

BusinessException and UserFriendlyException not shown on the client #9976


User avatar
0
trendline created

ABP ver 9.3.5 with micro-services architecture, the UserFriendlyException not shown on the razor page client when backend API throw a UserFriendlyException, below is the code section: A BusinessException threw but it cannot shown on the client side in a application service like below: `
public virtual async Task

        if (!result)
        {
            throw new InvalidVerificationCodeException();
        }

        var identityUser = await _phoneNumberLoginNewUserCreator.CreateAsync(input.PhoneNumber, input.UserName, input.Password, input.EmailAddress);

        return ObjectMapper.Map<IdentityUser, IdentityUserDto>(identityUser);
    }
    `

the InvalidVerificationCodeException is a BusinessException

I added an UserFriendlyException in the Controller like below: `
[HttpPost] [Route("register/by-phone-number")] public virtual async Task

            return result;
        }
        catch (BusinessException ex)
        {

            throw new UserFriendlyException(ex.Code);
        }
    }
    `
    it got below logs in the backend:
    `
    2025-10-08 17:38:45.887 +08:00 [WRN] ---------- RemoteServiceErrorInfo ----------

{ "code": null, "message": "EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode", "details": null, "data": {}, "validationErrors": null }

2025-10-08 17:38:45.887 +08:00 [WRN] EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode Volo.Abp.UserFriendlyException: EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode at EasyAbp.Abp.PhoneNumberLogin.Web.Controllers.PhoneNumberLogin.Account.LoginController.RegisterByPhoneNumberAsync(RegisterWithPhoneNumberInput input) at lambda_method3691(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.

then the client get a 403 forbidden HTTP Status code with the errors like below, it doesn't use UI throw a message: { "error": { "code": null, "message": "EasyAbp.Abp.PhoneNumberLogin:InvalidVerificationCode", "details": null, "data": {}, "validationErrors": null } }


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The UserFriendlyException not shown on the razor page client

    What is your razor page code?

    Thanks

  • User Avatar
    0
    trendline created

    [maliming] said: hi

    The UserFriendlyException not shown on the razor page client

    What is your razor page code?

    Thanks

    Not any specified code, just a form submit, send a phonenumber and a verification code to API side.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Use abp.ajax will show the messages.

    https://abp.io/docs/latest/framework/ui/mvc-razor-pages/javascript-api/ajax

  • User Avatar
    0
    trendline created

    Thanks your helping, maliming

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 25, 2025, 06:16
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.