Open Closed

Make BusinessException throw 400 Bad Request #6102


User avatar
0
ben.shelton created
  • ABP Framework version: v7.2.2
  • UI Type: MVC
  • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

We have a manager that is being called by an appservice in order to do some cross-modules validation checks. If the checks fail, then a BusinessException is thrown. The BusinessExceptions are currently returning Status 403 Forbidden when thrown. Is there a way to make them return Status 400 Bad Request instead?


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

    hi

    1. Map your business code to HTTP code. https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHttpStatusCodeOptions.cs#L15
    2. Override the https://github.com/abpframework/abp/blob/issue-18042/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs#L72 service.
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07