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!
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.
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.
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.
@@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.
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!
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.
Loved the depth up to which u covered this topic!!
feels like I am getting industry ready!!
You are amazing🤩
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.
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.
@@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.
DM(Dart Master)
When to create custom exceptions?
❤
Wow❤️
Hey
I guess if it was explained in Flutter it will be easier to understand