
Text version of the video
http://csharp-video-tutorials.blogspo...
Slides
http://csharp-video-tutorials.blogspo...
Angular CRUD Tutorial
https://www.youtube.com/playlist?list...
Angular CRUD Tutorial Text Articles & Slides
http://csharp-video-tutorials.blogspo...
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatAr...
When an Angular component needs data, there are usually 3 players
1. The Component itself
2. The Angular Service and
3. The Server Side Service
The first question that comes to our mind is, should we handle the service related errors in the service itself or in the component that consumes the service. According to Angular style guide, error inspection, interpretation, and resolution is something you want to do in the service, not in the component.
If all goes well the server side service provides data to the client side angular service and the Angular service provides it to the component, which then displays that data to the user.
However, sometimes the request may fail on the server or on the client. There are two types of errors that can occur.
The server may reject the request, returning an HTTP response with a status code such as 404 or 500. These are error responses.
Something could go wrong on the client-side such as a network error that prevents the request from completing successfully or an exception thrown in an RxJS operator. These errors produce JavaScript ErrorEvent objects.
The HttpClient captures both kinds of errors in its HttpErrorResponse and you can inspect that response to figure out what really happened.
So, the important point to keep in mind is, if the HttpErrorResponse is an instance of ErrorEvent, then it means that a client-side or network error occurred. If it's not an instance of ErrorEvent, then it means a server error occured.
Displaying the actual raw errors to the end user is bad for two reasons - First they are cryptic and does not make much sense to the end user and second they may contain sensitive information that could be useful for a potential hacker. That is why we are logging the actual error and returning a user friendly error message.
Finally, take the Observables returned by the HttpClient methods and pipe them through to the error handler.
With the release of rxjs version 5.5, we have Pipeable Operators that can be used along with the pipe() function. Before the introduction of pipeable operators, we used to chain operators as shown below.
So the point that I am, trying to make is
1. There are 2 types of operators in rxjs - Pipeable Operators and Patch Operators
2. Pipeable Operators are imported from rxjs/operators/
3. Patch Operators are imported from rxjs/add/operator/
4. Pipeable Operators have several benefits over Patch Operators. So if you have rxjs version 5.5 or later use pipeable operators.
5. Use the following link to read the benefits of pipeable operators
https://github.com/ReactiveX/rxjs/blo...
In our case, the angular service getEmployees() method is consumed by a Resolver service, and this resolver service provides the data to the LIST route. If there is an exception, the resolver fails and the target route, in our case the LIST route will not be activated. If a component is directly consuming the angular service getEmployees() method, then it is easy to catch the error observable and display the error message to the user.
However, when a resolver is involved, the target route is not activated if there is an error. So displaying an error message to the end user is a bit more involved.
In our next video, we will discuss handling errors and displaying error messages where there is a resolver between an angular service and the component.
asp.net core docker Angular httpclient error handling | |
144 Likes | 144 Dislikes |
25,028 views views | 524K followers |
Science & Technology | Upload TimePublished on 16 Jul 2018 |
Related keywords
wcf vs web api,tutorialspoint,csharp-video-tutorials.blogspot,tutorials dojo,csharp string format,central park 5,asp.net core github,craigslist nj,wcf one piece,asp.net core 3,server status,server jobs nyc,asp.net core swagger,credit karma,services group,tutorials by hugo,csharp corner,server error in '/' application,servers for minecraft,asp.net core dependency injection,services windows,asp.net core 3.0,wcf ria services,tutorialspoint c#,services angular,calculator,tutorialspoint tableau,services google play apk,asp.net core 3 release date,server job description,tutorials by a,servicenow,csharp assembly,csharp array,tutorialspoint python,services briefcase,asp.net core web api,wccftech,csharp enum,craigslist ny,server pro,server status ffxiv,csharp foreach,cheap flights,server memes,asp.net core hosting,services sas,services online,chase,tutorialspoint java,serverless architecture,tutorialspoint java compiler,server resume,wcf c#,server books,tutorialspoint javascript,services technologies gps,csharp to json,college football,csharp dictionary,server jobs,cvs,cnn,costco hours,tutorialspoint sql,wcf service application,server side rendering,tutorialspoint spring,serverless,wcf soap,tutorialspoint spark,wcf cat,asp.net core download,csharp to vb.net,wcf test client,cool math games,services & training hse colombia sas,servicestack,citibank,asp.net core identity,asp.net core logging,tutorialsystems,cunyfirst,wcf nba,csharp download,services fms publish announcement,wcfi foundation,services.msc no abre,csharp online,csharp operator,wcf authentication,asp.net core razor pages,server duties,asp.net core environment variables,tutorials near me,csharp random,server 2019,chernobyl,century 21,serverminer,services consultores,services consulting,services.msc,asp.net core configuration,csharp list,asp.net core tutorial,wcfm,wcfs international curriculum,asp.net core mvc,server hosting,chase online,wcf api,wcfi,costco,server jobs near me,capital one,server rack,tutorialspoint html,csharp interface,craigslist,tutorialsteacher,tutorialspoint reactjs,wcf dragon ball,asp.net core 2.2,services desk,tutorialspoint python 3,services transmission company sas,asp.net core signalr,services manager,csharp tutorial,tutorialspoint spring boot,asp.net core middleware,csharp online compiler,wcf web service,wcf 2019 nba,services tag dell,csharp switch,csharpstar,wcf tutorial,
Không có nhận xét nào:
Đăng nhận xét