Global Error Handling in .NET 8 - My Favorite Approach

Поділитися
Вставка

КОМЕНТАРІ • 28

  • @joofville
    @joofville 7 днів тому

    Your videos are great, really appreciate it. I’m joining your discord

  • @ahmedshahjr
    @ahmedshahjr 4 місяці тому +3

    Thanks for the amazing demo Amichai Mantinband

  • @Eirenarch
    @Eirenarch 4 місяці тому +13

    I don't understand the value of separate endpoint. Why not have a middleware that catches exceptions discriminates by their types, builds the appropriate ProblemDetails and writes it to the response

    • @amantinband
      @amantinband  4 місяці тому +4

      Both are solid choices. It mostly comes down to preference

    • @Dustyy01
      @Dustyy01 4 місяці тому +4

      There is no benefit in using the route approach like this. Normally you handle the exception using the IExceptionHandler interface and if you return false in the TryHandleError method, the route will receive the exception to further process (e.g. show a nice error html page). If you return true your exception is handled.
      I dont know any other reason why you want to use the route instead of the Interface in a plain API

    • @Fikusiklol
      @Fikusiklol 4 місяці тому

      @@Dustyy01 I agree aswell. If you want granular exception handling - IExceptionHandler is the way to go.
      However for easy/small services both approaches mentioned above are just fine.

  • @10Totti
    @10Totti 4 місяці тому +2

    Great tutorial, but why not use a new IExceptionHandler abstraction for managing exceptions ?

    • @amantinband
      @amantinband  4 місяці тому +2

      I would choose IExceptionHandler over this approach for larger applications that need the modularity. For smaller apps, I personally prefer this approach

  • @felipecosta9889
    @felipecosta9889 4 місяці тому +2

    Great content. One question. Is it best practice to throw exceptions in my code and catch them with global error handling? Or is it better to throw only exceptions that cannot be predicted?

    • @amantinband
      @amantinband  4 місяці тому +1

      This is exactly next Monday’s video

  • @ANTONZUBAREV
    @ANTONZUBAREV Місяць тому

    How can this be related to your ErrorOr ?

  • @solvestation
    @solvestation 4 місяці тому +1

    Great tutorial.
    I would like to ask if the implementation is usable in a .net 8 MVC project?
    Thank you @Amichai

  • @Buutyful
    @Buutyful 4 місяці тому

    perfect video 10/10

  • @xybersurfer
    @xybersurfer 4 місяці тому

    any tips on how to do global error handling in Blazor? ErrorBoundary doesn't seem to catch everything

  • @turcanuioangeorge4750
    @turcanuioangeorge4750 4 місяці тому +1

    What is the tool you used to highlight code? Or is it just done in post production

  • @afgone123456
    @afgone123456 4 місяці тому

    So if a client comes back with a traceid how would a developer find the real issue for that request? Are you saying we need to log it to db or something using the error endpoint?

  • @obinnaokafor6252
    @obinnaokafor6252 4 місяці тому +1

    What icon plugin are you using in your VS Code?

  • @SerafimMakris
    @SerafimMakris 4 місяці тому +1

    Good job. clean code as usual. i Hate you :D :D :D
    Ty @amantinband

  • @MartinoBordin
    @MartinoBordin 4 місяці тому

    Can we use it also for grpc services?

  • @harrisonwell1719
    @harrisonwell1719 4 місяці тому

    why you don't respond to questions in the comments?

    • @AslamNazeerShaikh
      @AslamNazeerShaikh 4 місяці тому +1

      Not sure if this is 100% true or not ?! 🤔

    • @amantinband
      @amantinband  4 місяці тому +1

      I can’t always keep up with all the comments.. sorry if I missed your previous message 🙏🏼