Video není dostupné.
Omlouváme se.

Better Application architecture with Error Handling | Expressjs

Sdílet
Vložit
  • čas přidán 30. 01. 2022
  • Error handling is something that is super important when it comes to huge production applications. For this video I will be using Expressjs with TypeScript, however do note that the theory is something that can be applied regardless of what language or framework you use.
    I got this in writing: frostzt.vercel.app/blog/error...
    Express Error Handling: expressjs.com/en/guide/error-...
    Express Async Errors: www.npmjs.com/package/express...

Komentáře • 16

  • @noahmilliken4259
    @noahmilliken4259 Před 7 měsíci

    This was really great. Ive been working on handling errors for a little over 2 weeks and this has really solidified things. Now to figure out database errors......

  • @snwdn
    @snwdn Před rokem +6

    Much better than the previous two error handling videos I watched! I have two questions:
    1. How can we throw and send multiple errors, like in a registration form if the user forgot to enter both an email and a password?
    2. Why does the object lose its prototype and we have to set its prototype to the prototype of itself?

    • @itsfzt
      @itsfzt  Před rokem +2

      Hey thanks! So to answer your questions,
      1. If you wanna do that I would say you can push to the errors array that we return in that way you're capable of returning more than one errors!
      2. This one I myself don't know why I did, so for clarification I don't think this should be needed! And here is the reason, `Object.setPrototypeOf` is used to assign prototypes to the object, however this is useful to setup inheritance when we use the `function` way of creating classes which is what JS have! So essentially it is useful to setup the prototypical inheritance chain! I think you can skip it (if using modern JS)!

    • @habibosaye
      @habibosaye Před 9 měsíci +1

      For multiple errors you can probably create an AggregateError class which takes an array of Errors and serializes them (you may need a helper function to aggregate specific Error classes), or maybe something specific like a ValidationError just for handling form validation errors. You can get creative here, but I suggest an AggregateError class would do just fine so as to avoid creating unnecessary error classes.

  • @mohammadjavadnajafi1782

    thank you so much for the great tutorial man! you mad my day : )

  • @abdulazeez.98
    @abdulazeez.98 Před rokem

    Excellent video 👍

  • @sony4481
    @sony4481 Před 8 měsíci

    Thank you very helpful!

  • @paulosoares8626
    @paulosoares8626 Před rokem

    thank you so much for the tutorial , helped me a lot, one question , what's the name of your vscode theme ?

  • @MuhammadAbduIIah
    @MuhammadAbduIIah Před rokem

    If you see on top right the status code is always 200. How’d you go about to fix that?

  • @user-dd7kw3ym5i
    @user-dd7kw3ym5i Před měsícem +1

    28:02 the "err instanceof CustomError" will always be true, so what's the point of checking

    • @itsfzt
      @itsfzt  Před měsícem +1

      That’s not the case ‘err instanceof CustomError’ will only be true when you throw an error that was an instance of CustomError means the CustomError and all of its Children classes, however the libraries that you use or anything else that is not your code will throw just an Error NOT CustomError that’s why the check!

    • @user-dd7kw3ym5i
      @user-dd7kw3ym5i Před měsícem

      @@itsfzt ok now I understand, I just got confused there.
      Just one more question: why not "err instanceof ValidationError"? cause it will make more sense as all the instances that you created are using "ValidationError"

  • @saferugdev8975
    @saferugdev8975 Před 2 lety +2

    you said delopment instead of development. a friend of mine also always says delopment hahah

    • @itsfzt
      @itsfzt  Před 2 lety

      Weird I generally slip up sometimes.

    • @saferugdev8975
      @saferugdev8975 Před 2 lety

      besides that very good and fluent english!

  • @VitthalInRajasthan
    @VitthalInRajasthan Před 2 měsíci +1

    Bro, class is really good but your copied indian english accent is hilarious. Please be original