Exceptions and Errors in Dart - Learn About Exceptions, Errors, Try, Catch, Finally and Much More

Поділитися
Вставка
  • Опубліковано 6 вер 2024

КОМЕНТАРІ • 12

  • @blueice1364
    @blueice1364 Рік тому +3

    This is a much needed topic that everyone seems to avoid or are afraid to go in details. When you work in large production app, it makes your life so much easier.
    Thanks a lot for gifting us with such in depth and quality content!

  • @srijanshovit844
    @srijanshovit844 Рік тому +1

    Loved the depth up to which u covered this topic!!
    feels like I am getting industry ready!!

  • @ashiquealimughal7684
    @ashiquealimughal7684 Рік тому

    Thank you for this amazing tutorial on Exceptions and Errors in Dart! It was very informative and easy to follow. I learned a lot about how to handle exceptions and errors in Dart using try-catch blocks and finally statements.
    I appreciate your effort in making this tutorial and sharing your knowledge with us. Keep up the great work!
    My refresher...
    An EXCEPTION is intended to convey information to the user about a failure that may happen at runtime. Because these exceptions are expected, you should catch them and handle them appropriately.
    An ERROR object represents a program failure that the programmer should have avoided. Examples include calling a function with invalid arguments or even with the wrong number of arguments or calling it at a time when it is not allowed.

  • @isurujn
    @isurujn Рік тому +2

    Hi Vandad, I have a question.
    Can you please explain what’s the use/advantage in creating a dedicated custom exception class over simply throwing a generic Exception? Seems like it's adding more code but I struggle to see the benefit.

    • @d-apps2699
      @d-apps2699 Рік тому +1

      I have the same doubt. The only thing I think it helps having our customs expections is that when we use, for example ,Firebase Crashlytics, when our exceptions are thrown it is easy to see which exception is happening since it shows the name of our custom exception, but putting that aside It seems just a lot more code to deal with.

    • @isurujn
      @isurujn Рік тому +1

      @@d-apps2699 That's a good point. I just asked ChatGPT and it also answered something along the lines of your thoughts.
      >
      Creating a custom exception class allows you to create more informative error messages and handle the error more specifically in your code. By creating a custom exception class, you can define custom properties for the exception object and create methods for handling the exception in a more tailored way.
      For example, suppose you have a function that performs a calculation and you want to throw an exception if the result of the calculation is invalid. You could create a custom exception class called InvalidCalculationResultException and define a property called result that stores the invalid result. This would allow you to create more informative error messages and handle the error more specifically in your code.
      In contrast, if you simply throw a generic Exception, you would not have any custom properties or methods available for handling the error in a more tailored way.

  • @victordziedzorm
    @victordziedzorm Рік тому +1

    You are amazing🤩

  • @minseokjeong1881
    @minseokjeong1881 Рік тому +1

    DM(Dart Master)

  • @okeyshourovroy2769
    @okeyshourovroy2769 Рік тому +1

    Wow❤️

  • @miguelyurivilca6867
    @miguelyurivilca6867 Рік тому +1

  • @d-apps2699
    @d-apps2699 Рік тому

    When to create custom exceptions?

  • @mohamadeaswy3452
    @mohamadeaswy3452 Рік тому

    Hey
    I guess if it was explained in Flutter it will be easier to understand