Тёмный
No video :(

ERROR HANDLING In ASP NET Core | Getting Started With ASP.NET Core Series 

Rahul Nath
Подписаться 32 тыс.
Просмотров 47 тыс.
50% 1

Hey Friends,
Exception handling or error handling is an important aspect of building applications. However much we want our applications to work fine, there will always be some unexpected cases. It's important that we handle these scenarios and return back appropriate messages. This is no different when building our APIs.
In this video, I will show you about exception handling in ASP NET Core Applications and the different ways we can handle them. I will also show you how to set up global error handling and the required middleware for that. Based on the feedback I received, I will also be showing some real-world examples of using Exception handling.
Additional Links:
🔗Handling Errors - docs.microsoft...
🔗Error Handling Approach (Ankit) - ankitvijay.net...
🔗Postman - www.postman.com/
Additional Watching
📹Model Binding - • MODEL BINDING in ASP.N...
📹 Return Types - • Controller ACTION RETU...
📹MIDDLEWARE - • MIDDLEWARE in ASP.NET ...
📹Dependency Injection - • DEPENDENCY INJECTION i...
📹Layering - • LAYERING in ASP.NET Co...
📹ASP NET Core Series - • ASP.NET Core
Come say hi! ✋
🌍 Blog - rahulpnath.com/
✉ Subscribe to my Newsletter - www.rahulpnath...
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
🎥 Recording Setup and Workflow - www.rahulpnath...
Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 211   
@rishabhmalhotra6474
@rishabhmalhotra6474 Месяц назад
just wanted to say that this is an excellent video for explaining global error handling. Kudos to you sir.
@RahulNath
@RahulNath 27 дней назад
Thank you Rishabh and glad you liked it! Hope you are liking the ASP Series bit.ly/asp-net-core-series
@bhuvankumarchauhan8958
@bhuvankumarchauhan8958 2 года назад
You will become the best teacher for .Net developers . Thanks for explaining thing in such a simple way
@RahulNath
@RahulNath 2 года назад
Thanks a ton Bhuvan. Hope you are enjoying the ASP Series bit.ly/asp-net-core-series
@abhishekks6782
@abhishekks6782 3 года назад
Thank you so much sir for this beautiful explanation. This is such a complex topic but made it to look very easy 🙏.
@RahulNath
@RahulNath 3 года назад
You are most welcome Abhishek. Do check out the full series here if you haven't already ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP And you can call me Rahul 😀
@uchitesting
@uchitesting Год назад
I love Command line since I used to be trained sysnet admin. Today as a developer on a VM I face terrible slowdowns with graphical tools. On a CLI I do the action in no time. I was not given a VS license for a while and I had to deal with .NET CLI. This is nice to know those options too. It may sound foolish but sometimes using dotnet CLI unlocked strange situations compiling through VS did not help. Less often it can be the other way around. Anyway I am here to learn about that error handling stuff. I just learnt there is a way to globally handle exceptions and that can be handy for a task I am given to setup logging. EDIT: After having watched the video it is not talking about what I heard about but that is very interesting.
@kumaramber6593
@kumaramber6593 2 года назад
I find your videos incredibly helpful for someone like me who is getting started in .net core.. Keep up the good work 👍
@RahulNath
@RahulNath 2 года назад
Thank you Kumar . happy to hear that. Do let know if there are specific topics that you would like covered.
@shahinquraishi9944
@shahinquraishi9944 2 года назад
P
@shahinquraishi9944
@shahinquraishi9944 2 года назад
@@RahulNath p
@naveenbaghel2936
@naveenbaghel2936 2 года назад
I can see your MVP award in background....
@RahulNath
@RahulNath 2 года назад
Yeah it's there on the shelf behind me 😀
@MrRikiJane
@MrRikiJane 2 года назад
awesome video
@RahulNath
@RahulNath 2 года назад
Glad you enjoyed it and hope you are enjoying the full series bit.ly/asp-net-core-series
@n0wWhat
@n0wWhat 2 года назад
Great content, Quality presentation. Thanks for sharing
@RahulNath
@RahulNath 2 года назад
My pleasure! The full series for ASP NET is here in case you haven't come across them bit.ly/asp-net-core-series
@GrtAngel
@GrtAngel 9 месяцев назад
That's awesome 👍
@RahulNath
@RahulNath 9 месяцев назад
Thank you Avinash! Hope you are liking the series 👍
@vineethkumartg4111
@vineethkumartg4111 3 года назад
Hi Rahul, Your Video contents are really useful and helpful with Realtime cases, It would be better if you could also use slides .So that we will understand some theory part as well. At the start of the videos you can show the Agenda, explanation of the concepts and at the last you can summarizes what are all the steps required or done to implement the logic.. Can you also provide a Video on Serilog,intergrate Serilog with AWS elastic search and Kibana.
@RahulNath
@RahulNath 3 года назад
Glad you like it Vineethkumar. And a great suggestion on the slides. I will post a poll on the channel to see the general opinion too. Slides will add in more effort on my side, but happy to do if a lot of people think it will be useful 😀 Added Serilog to my list. Hope you have watched my video on Logging ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dxBlBltEDRs.html Thank you again for the suggestion and the feedback!
@LogicOpsLab
@LogicOpsLab 3 года назад
You have really good quality content, Rahul. I was inspired from your content to create my own RU-vid channel. Thanks a lot!
@RahulNath
@RahulNath 3 года назад
Wow that's so nice to hear. And super glad to know you started a RU-vid channel. I will check out the videos there.
@LogicOpsLab
@LogicOpsLab 3 года назад
@@RahulNath My pleasure, Rahul.
@zarazada
@zarazada 3 года назад
The best teacher ever
@RahulNath
@RahulNath 3 года назад
Thank you Zarifa. Hope you have checked out the full series ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Do let know if you have any topic suggestions.
@techrelated2417
@techrelated2417 3 года назад
Exceptional Video on handling Exception !! Thank you Rahul !!
@RahulNath
@RahulNath 3 года назад
Thank you 😀
@alwaseem5309
@alwaseem5309 Год назад
As usual, highly quality.
@RahulNath
@RahulNath Год назад
Glad you think so!
@kakmca
@kakmca 2 года назад
Oh my God, you are rocking man! Thank you very much for this beautiful video. This is what exactly I'm looking for.
@RahulNath
@RahulNath 2 года назад
Glad I could help! Do check out the full series here bit.ly/asp-net-core-series
@nirajjoshi3349
@nirajjoshi3349 Год назад
superb video I found on you tube
@RahulNath
@RahulNath Год назад
Thanks and welcome. The full series on ASP is here bit.ly/asp-net-core-series
@nirajchandrajoshi
@nirajchandrajoshi Год назад
@@RahulNath Thanks a ton you replied me. I will view this.
@RahulNath
@RahulNath Год назад
@@nirajchandrajoshi Sure Niraj. Let me know in case you have specific questions, suggestions or feedback
@Adarshsrivastavahigh
@Adarshsrivastavahigh 2 года назад
Wonderful demonstration of the concepts. Thank you very much sir.
@RahulNath
@RahulNath 2 года назад
You are most welcome Adarsh!!
@sirpasricharan4986
@sirpasricharan4986 3 года назад
Great Explanation Rahul, Thankyou so much
@RahulNath
@RahulNath 3 года назад
Thank you Sirpa!
@bhavyashah8847
@bhavyashah8847 3 года назад
This is something I was looking for my project. Handling error from a centralised system will surely save a alot of development efforts. Just had one doubt Why did you make your domain exception class as abstract ? What if, we don't make it abstract?
@RahulNath
@RahulNath 3 года назад
Thank you Bhavya. It's optional to mark it as abstract. (22:25) Only if you want to make sure across the code base you want more specific exceptions to be created instead of using the base class always. Hope that helps.
@AngelPerez-pp2hj
@AngelPerez-pp2hj 2 года назад
Thank you so much!!! Greetings and blessings from Perú! 👍 👍
@RahulNath
@RahulNath 2 года назад
Thank you too!
@Azcraz
@Azcraz 3 года назад
Great video and explanation once again!
@RahulNath
@RahulNath 3 года назад
Thanks again!
@ashutoshsrivastava2275
@ashutoshsrivastava2275 3 года назад
Great !! I have watched your other videos also. keep rocking. Thanks for your efforts.
@RahulNath
@RahulNath 3 года назад
Thanks a ton, glad you like them!
@soulfabuk
@soulfabuk 2 года назад
Fantastic video as always Rahul. Plenty of detail that is explained in a clear but thorough way. Thanks for helping the developer community!
@RahulNath
@RahulNath 2 года назад
Great to hear that, thank you.
@rahulmishra111
@rahulmishra111 Год назад
It would be better if you can give download also for the shown projects ... Great video
@RahulNath
@RahulNath Год назад
Usually I have the path to the repo in the description. Missed uploading this one. Will see if I can find it and upload it again. All repos are usually here rahulpnath.visualstudio.com/RU-vid%20Samples/_git/aspnet-startup
@onyoursideabsolutely2268
@onyoursideabsolutely2268 Год назад
Hi Rahul, Thanks a lot for to the point videos. I really appreciate the content and the way you teach. I am able to understand the concept with the way you explain it. Thanks!
@anurag3487
@anurag3487 3 года назад
nice one Rahul. Well explained.
@RahulNath
@RahulNath 3 года назад
Happy you like it Anurag! (Still working out the security related topics. Lots of reading to do 😀)
@anurag3487
@anurag3487 3 года назад
@@RahulNath I have also started reading, and have understood a lot of security related concepts. Please take your time.
@akhilkumarp
@akhilkumarp 2 года назад
Thanks for the detailed explanation, keep doing more🎉
@RahulNath
@RahulNath 2 года назад
Sure and happy you liked it Akhil. Hope you are enjoying the series bit.ly/asp-net-core-series
@ramashankar2750
@ramashankar2750 3 года назад
Certain Exceptions need additionally a code mining strategy and we can use the ctor/BaseTrace (Assembly.GetCallingAssembly().Getname().Name ) added to the middleware to deliver a multilevel ring trace on a circular queue available on production mode, to locate the path of code.
@RahulNath
@RahulNath 3 года назад
yes adding in more logs helps, I usually have a request id to correlate across all the messages.
@ramashankar2750
@ramashankar2750 3 года назад
@@RahulNath Design for a Pitstop of Diagnostics to achieve functionality, refer you to the book Art of Programming by Edgar Dijkstra.
@RahulNath
@RahulNath 3 года назад
@@ramashankar2750 Great will check it out!
@mayureshm2534
@mayureshm2534 3 года назад
keep it bro, its awesome!!
@RahulNath
@RahulNath 3 года назад
Thank you Mayuresh! Do check out the full series here ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@bloopers2967
@bloopers2967 3 года назад
Damn bro your explanation is awesome, need more videos on aap.net core❤️❤️❤️ and you deserve more subscribes
@RahulNath
@RahulNath 3 года назад
Thank you for the love and glad you like it. Hope you checked out other videos in this series ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Do let know if you have specific topics that needs to be covered.
@bloopers2967
@bloopers2967 3 года назад
@@RahulNath Yes watching the whole series, preparing for an interview
@bloopers2967
@bloopers2967 3 года назад
@@RahulNath Yes, can you make detailed videos on both generic and non generic collections. More focused on hashmap and dictionary
@fastturtle8429
@fastturtle8429 3 года назад
Great detailed video sir, thanks for sharing
@RahulNath
@RahulNath 3 года назад
So happy to hear that Mahmadhusen. Do check out the full series here if you haven't already ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP And you can call me Rahul 😀
@deepakmitawa8106
@deepakmitawa8106 2 года назад
Thank you Rahul to made this video. Very good explainaion.
@RahulNath
@RahulNath 2 года назад
Thanks and welcome Deepak!
@saritalad8923
@saritalad8923 2 года назад
Great explanation. Rahul, can u sovle my problems, I am 60+ woman, so I find your speed of teaching somewhat faster. But definitely best. My problem is As follows I want to make an apl to be cobsumed by angular, it has entity, employee with contenment if address, so how to write put method so that data of employee and address get updated togather.
@saritalad8923
@saritalad8923 2 года назад
Employee with id, name, salary and addressid as fireign key, with another entity address id, street, city, pin
@RahulNath
@RahulNath 2 года назад
Happy to help. What issues are you facing in particular?
@joe-sydney-au
@joe-sydney-au Год назад
You should tell us you are a 16yo girl, not 60+ woman ! Then everyone in here will jump to help you 😍😁😆🤣
@elCOMPAiler
@elCOMPAiler 3 месяца назад
Amazing explanation thanks a lot Rahul. New subscriber here!
@RahulNath
@RahulNath 3 месяца назад
Glad you are liking the content.
@raagasongs
@raagasongs 3 года назад
superb..
@RahulNath
@RahulNath 3 года назад
Thank you Rajesh!
@fahmifarhat7076
@fahmifarhat7076 2 года назад
Thanks a lot Rahul. You have made it very clear for me !
@RahulNath
@RahulNath 2 года назад
Most welcome Fahmi!
@i.paradox
@i.paradox 2 года назад
Shower of love Rahul
@RahulNath
@RahulNath 2 года назад
Thank you Sahil! Do check out the full series if you haven't already bit.ly/asp-net-core-series
@akshayanvekar8713
@akshayanvekar8713 3 года назад
You earned a subscriber. Nice explanation.
@RahulNath
@RahulNath 3 года назад
Glad you like it Akshay. Do check out the other videos in this series ru-vid.com/group/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Let know in case you want any particular topics to be covered.
@akshayanvekar8713
@akshayanvekar8713 3 года назад
@@RahulNath Can you create a Unit Test tutorial for asp.net core
@RahulNath
@RahulNath 3 года назад
@@akshayanvekar8713 Sure yes. Coming up soon! Meanwhile do checkout my AutoFixture playlist ru-vid.com/group/PL59L9XrzUa-mItWClbGuMEK5oQpU2onCq It's very helpful with writing tests.
2 года назад
Thank you very much it was just what I needed to implement in my API and you made it very simple, thanks again!
@RahulNath
@RahulNath 2 года назад
Glad it helped Joshué! Do check out my full series here bit.ly/asp-net-core-series I'm sure you will like it!
@TheMezanine
@TheMezanine Год назад
Thanks a lot for the great video with clear explainations!!!!
@RahulNath
@RahulNath Год назад
You are welcome and glad you liked it Medoune! The full series for ASP is here bit.ly/asp-net-core-series
@psmith189
@psmith189 2 года назад
Great Explanation!
@RahulNath
@RahulNath 2 года назад
Glad it was helpful! Do check the full series bit.ly/asp-net-core-series I'm sure you will like it!
@aaronbcj
@aaronbcj 9 дней назад
One request, is to make your face circle small so it doesn't hide the code.
@RahulNath
@RahulNath 9 дней назад
Thank you for the feedback! I have been more cautious about this in my recent videos and making sure it does not block important parts! Hope you are enjoying the series bit.ly/asp-net-core-series
@aaronbcj
@aaronbcj 9 дней назад
As mostly I use mobile to watch while commuting, it becomes even harder but good that you are aware. 👍
@RahulNath
@RahulNath 9 дней назад
@@aaronbcj Yup makes sense / let me know if you face the same problem in more recent videos! Thanks again for the feedback!
@adhivenkatesh3431
@adhivenkatesh3431 2 года назад
Hi Rahul , great effort , thanks for your video.
@RahulNath
@RahulNath 2 года назад
Thanks and welcome Adhi. Happy New Year. Check out the full series here which has lot more such videos bit.ly/asp-net-core-series
@adhivenkatesh3431
@adhivenkatesh3431 3 месяца назад
@@RahulNath Thanks Rahul , your videos are always different and advanced
@RahulNath
@RahulNath 3 месяца назад
@@adhivenkatesh3431 Thank you Adhi and happy that you find them useful.
@aaqibkhan8360
@aaqibkhan8360 2 года назад
Very well explained!
@RahulNath
@RahulNath 2 года назад
Glad you liked it Aaqib. Hope you are enjoying the series bit.ly/asp-net-core-series
@subrataranjanpal6518
@subrataranjanpal6518 3 года назад
Really helpful your information!! Thank U.
@RahulNath
@RahulNath 3 года назад
Glad they are helping Subrata!
@madhujonnabattla6479
@madhujonnabattla6479 Год назад
Hi Rahul, Your Videos are really awesome, I would like to hear a solution for the exception in the Finally block, How can we handle these exceptions in the real project. Thanks in advance.
@RahulNath
@RahulNath Год назад
Thank you Madhu. When you are catching an Exception the code likely you are expecting for it in that case what would you want the code to do? If you can explain the scenario a bit more maybe I could help.
@asht3118
@asht3118 3 года назад
Great video
@RahulNath
@RahulNath 3 года назад
Glad you like it Ash! Do check out my other videos in this series 😀
@AbdulSamad-by4fx
@AbdulSamad-by4fx 2 года назад
Thank you sir for the great explanations :)
@RahulNath
@RahulNath 2 года назад
Most welcome! Do checkout the full playlist here bit.ly/asp-net-core-series
@syamchandar9780
@syamchandar9780 Год назад
Hi Rahul, After seeing this video I got confused between Middleware and filters, could you please make a video on this difference and when to use Middleware and filters.
@RahulNath
@RahulNath Год назад
Does this help you Syam? learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-6.0&WT.mc_id=AZ-MVP-5003875#use-middleware-in-the-filter-pipeline And this SO post also explains it a bit more stackoverflow.com/questions/42582758/asp-net-core-middleware-vs-filters
@panirajn
@panirajn 3 года назад
very nice tutorial
@RahulNath
@RahulNath 3 года назад
Thanks for watching Paniraj!
@ChandanKumar-es7bz
@ChandanKumar-es7bz 2 года назад
Hi Rahul. I have watched your videos recently and they are really good
@RahulNath
@RahulNath 2 года назад
Thank you Chandan. Happy they are helping. Here is the full ASP Series in case you missed it bit.ly/asp-net-core-series
@ChandanKumar-es7bz
@ChandanKumar-es7bz 2 года назад
​@@RahulNath​ Thanks Rahul. Can you please make a video on role based authentication in web api using microsoft graph
@RahulNath
@RahulNath 2 года назад
@@ChandanKumar-es7bz Is this what you are looking for? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-HVruBWuKnYw.html www.rahulpnath.com/blog/dot-net-core-api-and-azure-ad-groups-based-access/
@smrsgv
@smrsgv 10 месяцев назад
👍
@RahulNath
@RahulNath 8 месяцев назад
😀
@harishkommuri5350
@harishkommuri5350 3 года назад
Thanks for the Knowledge Share, I found it useful. I have a question - In ExceptionHandler Middleware, the catch blocks grows as many we have different Domain Exceptions, could you suggest on A better way to handle, as catch blocks grows with different domain exception classes? This is on the Interview Questions I have got, please suggest..
@RahulNath
@RahulNath 3 года назад
Thank you Harish. The ExceptionHandler implementation in this blog post covers once such option to clean up the long list ankitvijay.net/2021/04/21/consistent-error-handling/ Let know if something like that is what you are looking for.
@1212Times
@1212Times 2 года назад
YOU ARE PERFECT
@RahulNath
@RahulNath 2 года назад
Haha definitely not, but thank you 😀 Hope you are enjoying the series bit.ly/asp-net-core-series
@NithinPrathapan
@NithinPrathapan Год назад
Very useful video. Rahul, is there any way we could capture the managed errors as well? For example, if we want to perform a global cache reset if some managed if exceptions occurred. In our case, it is already captured by the library we are using.
@adityaghosalkar431
@adityaghosalkar431 2 года назад
Rahul is just awesome guy from 2050
@RahulNath
@RahulNath 2 года назад
Haha !! Thank you and happy you liked it. Check out the full series here bit.ly/asp-net-core-series
@0GERA0
@0GERA0 Год назад
whats the difference with this error handling to the controller filter globalexception : options.Filters.Add(); or which is the best way?, thanks for your videos
@syedabdullah965
@syedabdullah965 2 года назад
Hey Rahul, Thanks for the video. Just want to ask that how to register middle ware in .net 6 as there is no Startup.cs file in this version. So ?
@RahulNath
@RahulNath 2 года назад
It's slightly changed places - In case you didn't find it already - docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0&WT.mc_id=AZ-MVP-5003875 Does that help?
@NikithaGurram
@NikithaGurram Год назад
Hai,rahul please explain the concepts in realtime examples.... don't use wheatherforcate for everytime
@RahulNath
@RahulNath Год назад
Thank you Nikitha for the feedback. The idea with these videos was to explain concepts from a known starting point. I figured the existing default template app was the best place for this. If not it's hard to set the right context to explain the different concepts from a fully setup project. I have tried to include as much real world concepts/problems you come across, but would definitely would have missed heaps. Anything in particular you are looking for or you feel missing?
@NikithaGurram
@NikithaGurram Год назад
@@RahulNath thank you for your response rahul but what i am saying is if you can apply the concepts in curd operations i think its helps a lot for freshers... That's way i am asking any way your vedio's helps me alot thank you rahul
@RahulNath
@RahulNath Год назад
@@NikithaGurram Sure will keep that in mind - Glad you find the videos useful Nikitha 👍
@DWCmoose
@DWCmoose 6 месяцев назад
But isn't wrapping await next(context) in the try catch the same as having try catch all over your controller actions? this would cause a performance hit across the application won't it?
@balajir391
@balajir391 3 года назад
Filters and Middleware. When should we use filters ? When should we use Middleware. ?
@RahulNath
@RahulNath 3 года назад
The official docs here has some good suggestions around that _"Prefer middleware for exception handling. Use exception filters only where error handling differs based on which action method is called. "_ Read more here 👉 docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-5.0#exception-filters Let me know if you have further questions.
@suryazn4575
@suryazn4575 Год назад
Hi Rahul, I appreciate your presentation, have few doubts can we use Enum instead of Summaries Array?
@balajithirunavukarasu7494
@balajithirunavukarasu7494 2 года назад
please take session for .net core MVC
@RahulNath
@RahulNath 2 года назад
Thank you for the suggestion Balaji. Any specific topics you would like covered? (Not sure how soon I will do it though, since I've not been working much on MVC)
@balajithirunavukarasu7494
@balajithirunavukarasu7494 2 года назад
@@RahulNath Thank You. can you take real time example for filters like Authorization Filter and , Exception Filter in .NET core
@rohan4rich
@rohan4rich 3 года назад
Is it mandatory to return concrete type if we are implementing our custom ExceptionMiddleware from action method or we can use IActionResult also ?
@RahulNath
@RahulNath 3 года назад
Hey Rohan, You can very well return IActionResult. Check out the differences between those in this video where I talk about it in detail ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-O9ZQ0O9uJ2E.html. Do let me know in case you have additional questions about this.
@raagasongs
@raagasongs 2 года назад
Hi Rahul, How are you? If you get a chance please do videos on .Net core microservices
@RahulNath
@RahulNath 2 года назад
I am good Rajesh and hope you are too. Thank you for reminding me on this, I do have some planned but haven't reached to it yet. Any cloud tech preferences for you on it, or are you ok if it's either Azure or AWS?
@raagasongs
@raagasongs 2 года назад
@@RahulNath - Thanks for reply. I am fine with Azure. I will wait for microservices videos.. Finally I like your videos and keep it up. It would help more peoples like me.
@RahulNath
@RahulNath 2 года назад
@@raagasongs Thank you !!
@callegarip
@callegarip 3 года назад
Thanks for the video. I have a question. What if I have multiple ExceptionHandlingDomains? (maybe I have a few different projects to handle different areas of the business in my app) How my ExceptionHandlingMiddleware is aware of what ExceptionHandlingDomain to use?
@RahulNath
@RahulNath 3 года назад
Might need more details. But the handler can be extended to switch case on any Exception Type. Check this gist (from a friend of mine) gist.github.com/ankitvijay/168c41f3abb3e817375be05e7b2e7083#file-2_exceptionhandler-cs for an example Is that what you were looking for? What issues are you particularly facing?
@callegarip
@callegarip 3 года назад
@@RahulNath I am not running into issues yet b I just started implementing error handling and I watched your video and I’d like to implement it. So let me give you more details. I have a multi layer project. I called ManagerXXX to a project that handle certains things in the app. I think you called it Domain project. You could also think my ManagerXXX like my services. So I want to create a custom ManagerXXXHandlingException for each of those projects I have. My question was how can I make my ExceptionHandlerMidleware to be smart to decide what type of exception to use. I know that if I just keep adding CATCH CATCH CATCH… for all the ones I have on each manager will work, but that seems to be odd. I was wondering if there is a pattern for this scenario.
@callegarip
@callegarip 3 года назад
I just saw the gist in your link. I think there is something there that could work for me. I will take a look at it closer.
@RahulNath
@RahulNath 3 года назад
@@callegarip Sure ok. let me know how that goes and if you have additional questions.
@callegarip
@callegarip 3 года назад
@@RahulNath thank you very much. You are awesome!
@mohsenghahremani508
@mohsenghahremani508 2 года назад
How do you implement this in an Azure function since the azure function has some work around? Can you explain ?thanks.
@RahulNath
@RahulNath 2 года назад
With Azure Function since the code is more isolated I would handle it within the function handler code. if there are a lot of functions, I might add a base class to handle API calls and implement common handling there. I do have couple of videos around Azure Functions www.rahulpnath.com/blog/getting-started-with-azure-functions/ www.rahulpnath.com/blog/dependency-injection-in-azure-functions/ Let me know if that answers your question or if you have additional questions.
@keerthang5557
@keerthang5557 3 года назад
Hi sir, can you make a tutorial video on worker service?
@RahulNath
@RahulNath 3 года назад
Hey Keerthan, Which worker services are you referring to? And you can call me Rahul 😀
@keerthang5557
@keerthang5557 3 года назад
@@RahulNath It's worker service in asp.net core ( Hosted services)
@RahulNath
@RahulNath 3 года назад
@@keerthang5557 Thank you Keerthan for clarifying. I am guessing this is what you are referring to? docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-5.0&tabs=visual-studio Great Suggestion. Yes, I will do one on that.
@keerthang5557
@keerthang5557 3 года назад
@@RahulNath Yes brother, that's the one
@RahulNath
@RahulNath 3 года назад
@@keerthang5557 Sure will do!
@vinothrajendran858
@vinothrajendran858 3 года назад
Hi Bro. Thanks for this video. I have one doubt. Can we simply use throw new exception kinds inside the code ? Is that a proper way?
@RahulNath
@RahulNath 3 года назад
Sure you can - but it becomes limiting. Having specific or categorized domain exceptions allows you to capture and handle for it at central handlers. This makes it more powerful. Also when you look at logs you can immediately filter out based on the type of exception. So my preference is generally to create specific exceptions, but nothing stopping you from doing new Exception("Message"). Hope that helps
@vinothrajendran858
@vinothrajendran858 3 года назад
@@RahulNath Thanks bro. Continue doing Azure related stuffs with .Net core. And also do containerization
@RahulNath
@RahulNath 3 года назад
@@vinothrajendran858 Cool thanks
@susus999
@susus999 3 года назад
Hi@rahul....I have deployed dotnet3.1 project which have .msi setup...when I am deploying .msi is not getting triggered and the deployment fails saying website not found....Any suggestions 🙏Thanks in advance
@RahulNath
@RahulNath 3 года назад
Hey Sai, that is a broad question. Why are you using MSI to deploy a website? Where are you installing this to? Is this a MSI distributed for your clients?
@susus999
@susus999 3 года назад
@@RahulNath I am installing to the web app on azure.....Yes it is distributed....I am giving silent installation command on inline script post deployment which dint work and also bat command also failed.....Thanks for all the learning you are providing 🙏
@sandeep19830
@sandeep19830 2 года назад
Hi Rahu Do you have microservices and Circuit Breaker Pattern vedio
@RahulNath
@RahulNath 2 года назад
I don’t have one specific to micro services. But I talk about this pattern in this video. Is that what you were looking for ? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-z6YcU0PW_9E.html
@usamatahir394
@usamatahir394 3 года назад
great (y)
@RahulNath
@RahulNath 3 года назад
Thank you Usama 😀
@DjHomerr
@DjHomerr Год назад
Hello Rahul, could you explain why the lifetime of a Exception Handling Service is transient and not scoped?
@RahulNath
@RahulNath Год назад
since there is no state to be managed in there. Any reason you are looking at why it needs to be scoped?
@DjHomerr
@DjHomerr Год назад
@@RahulNath No particular reason. I just couldn't understand why transient, and what does the lifetime of a exception handling service even mean? I have my web api with a couple of services that just deal with basic crud operations involving a database, and scoped lifetime seemed like a good choice for those. So i thought the exception handling middleware service would be the same.
@RahulNath
@RahulNath Год назад
they make sense only if you need to keep context + state in the context of that scope. In this case it isn't required - Do check out my DI video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YR6HkvNBpX4.html And other videos in this series bit.ly/asp-net-core-series
@DjHomerr
@DjHomerr Год назад
@@RahulNath Thank you very much for the response!
@sagerofgyan
@sagerofgyan 3 месяца назад
how to handle 403 in .net core web api
@asht3118
@asht3118 3 года назад
Why you use Rider not visual studio?
@RahulNath
@RahulNath 3 года назад
Because it is easier to navigate into library implementation code, like I do at 4:56
@vineeths1710
@vineeths1710 2 года назад
Hi i have created an asp.net core web api and added custome middleware but its still throwing the exception before going to middleware catch block..do wee need exception filter to handle that?
@RahulNath
@RahulNath 2 года назад
Yes I think so - hope you were able to catch that?
@sureshp34
@sureshp34 2 года назад
Hi Rahul, I would like you to post a new video on "CancellationToken" in HttpClient request.
@RahulNath
@RahulNath 2 года назад
Great suggestion Suresh. This is something on my list. I will try and do something on it.
@sureshp34
@sureshp34 2 года назад
Thank you@@RahulNath
@chinjuskitchen4234
@chinjuskitchen4234 2 года назад
Can u add more videos about aks
@RahulNath
@RahulNath 2 года назад
Thank you for the suggestion. Not sure how soon though, I havent been doing a lot of aks.
@RahulNath
@RahulNath 2 года назад
Great channel you have got yourself Chinju! And great to see you are from Kerala too (I am as well 😀)
@Blr046
@Blr046 3 года назад
Is it possible to pass multiple parameters to "DomainNotFoundException" class and access those parameters in ExceptionHandlingMiddleware class ?
@RahulNath
@RahulNath 3 года назад
Sure. Any number of parameters and types as you wish. it’s a custom type, so you can control it. let me know if you are running into any issues
@Blr046
@Blr046 3 года назад
@@RahulNath Yes, I am able to pass the arguments, but I don't know how access those parameters in global ExceptionHandlingMiddleware class. I want to print the exception in the log in common place.
@AbhinavSingh-ov7pj
@AbhinavSingh-ov7pj 2 года назад
This is good but model validation error are not caught in above solution. Just need code where we can caught exception and Model validation at same place so that api can return common response.
@RahulNath
@RahulNath 2 года назад
Hope you were able to resolve this.
@AbhinavSingh-ov7pj
@AbhinavSingh-ov7pj 2 года назад
@@RahulNath I have not got solution
@joe-sydney-au
@joe-sydney-au Год назад
It was a lot easier with the previous .NET v4.x; We could do this out of the box : 1) return Request.CreateErrorResponse(HttpStatusCode.NotFound, message); 2) throw new HttpResponseException( Request.CreateErrorResponse( HttpStatusCode.NotFound, message) ); Can anyone show an example where the http Client Library (e.g. axios, fetch) can actually capture the status-code, and custom message thrown by the web-api DOT NET CORE BULLSHIT?
@utkarshdubey7993
@utkarshdubey7993 7 месяцев назад
triggered inaan hum aapse milne a rahe hain march mein
@RahulNath
@RahulNath 7 месяцев назад
sorry, didn't understand?
@prototype8861
@prototype8861 2 года назад
Indians start explaining anything by first creating a project. You all.shall.see one more time how to create a project. And name it "my project".
@RahulNath
@RahulNath 2 года назад
Not sure about all "Indians" Emre, I do that to start from familiar grounds to someone new to a concept. This helps teach more easily than starting from a big code base. Not sure if you watched past the project creation and had any suggestions on that. Thank you!
@techpc5453
@techpc5453 Год назад
@mayurbanta
@mayurbanta 2 года назад
Awesome content, Thank you ! Can we have something like this in a method. Public int SaveEntity() { try { context.SaveChanges(); } catch(DbUpdateException exception) { throw new SomeDomainException(exception?.InnerException); } } and catch that "SomeDomainException" in middleware.
@RahulNath
@RahulNath 2 года назад
Yes, you could do that - nothing stopping you from doing that. It might soon be a lot of exceptions depending on the granularity of these classes.
@mayurbanta
@mayurbanta 2 года назад
@@RahulNath Thanks for the reply.
Далее
SHIRT NUMBER OR SWIM 🙈💦
00:32
Просмотров 6 млн
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 256 тыс.
.NET 6 - Web API Global Exceptions Handling 🌐 ❌
1:14:00
SHIRT NUMBER OR SWIM 🙈💦
00:32
Просмотров 6 млн