Master Exception Handling in Spring Boot: @ExceptionHandler & @ControllerAdvice Explained

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ธ.ค. 2024

ความคิดเห็น • 21

  • @nadeemshehnawaz4610
    @nadeemshehnawaz4610 4 วันที่ผ่านมา +1

    Truly helpful, cleared all my doubt about the necessity of this global exception handler. Thanks and keep growing 😊

  • @lavanyateku2357
    @lavanyateku2357 วันที่ผ่านมา +1

    I sreached many videos but this is truly helpful, very clearly explained thank you💐

  • @abhishekprasad7568
    @abhishekprasad7568 28 วันที่ผ่านมา +2

    Great Content bro, where are u from so many days youtube is doing wrong with u you should be top of all tutor

  • @tanulakhwani
    @tanulakhwani หลายเดือนก่อน +1

    Very much Helpful.

  • @rudranaskar763
    @rudranaskar763 4 วันที่ผ่านมา +1

    Bro please make a video on Aunthentication and jwt 0:19

  • @universal4334
    @universal4334 3 หลายเดือนก่อน +1

    Let's say in my service class, I'm doing multiple operations to return something to controller. Out of those many operations in service, i may get 10 different exceptions, so do i need to catch specific exceptions or directly catch generic exception in service and throw our custom exception, so that even we don't handle specific exception or anything in controller, restcontroller advice catches our custom exception

    • @CodeSnippetByChetanGhate
      @CodeSnippetByChetanGhate  3 หลายเดือนก่อน +1

      Great question! It's a good practice to catch specific exceptions as much as possible in your service layer, as it gives more clarity on what went wrong and helps you handle different scenarios appropriately.
      However, if you have several different exceptions, you can group them and map them to a custom exception, which can then be handled by the @ControllerAdvice.
      For example, you could catch specific exceptions like NullPointerException, IllegalArgumentException, etc., in your service, then wrap them in a custom exception (e.g., CustomServiceException). This custom exception can be handled centrally in @ControllerAdvice.
      Catching a generic Exception directly in the service might hide the actual problem, making debugging difficult. Always try to handle known exceptions first, then fall back on generic handling if necessary. This way, your @ControllerAdvice can consistently handle the custom exception and return a proper response to the client.

    • @kapilpandey806
      @kapilpandey806 3 หลายเดือนก่อน

      How much time to enough to learn spring boot from scratch? And what should I need to learn for 2 to 3 year experience person . Earlier worked on core java and SQL .please guide me

  • @AdarshSingh-j1q
    @AdarshSingh-j1q 2 หลายเดือนก่อน +2

    Don't use dark theme,
    In intelij and postman,
    Unable to see text.

  • @ijaysingh5762
    @ijaysingh5762 2 หลายเดือนก่อน +1

    can you provide notes

  • @mahady_hasan_fahim
    @mahady_hasan_fahim 2 หลายเดือนก่อน +2

    Thanks you. I learn new topics from your video. But you don't provide source code -_-

  • @aastha4708
    @aastha4708 17 วันที่ผ่านมา +1

    I dont know why all youtubers are promoting intellij ide Its not clearly visible..??