Angular Tutorial - 22 - HTTP Error Handling

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 121

  • @Codevolution
    @Codevolution  6 лет назад +71

    Catch and Throw was updated with Rxjs version change. Please watch video #31 for a working example.

    • @ايمانعبدالقادر-ص9خ
      @ايمانعبدالقادر-ص9خ 6 лет назад +4

      شكرا

    • @Vilmis
      @Vilmis 5 лет назад +16

      @Codevolution, you should put in description the latest source code for Angular 7 as you example doesn't work and confuses people.

    • @punkkauz
      @punkkauz 5 лет назад +1

      There is no working example there... :(

    • @codersauthority
      @codersauthority 5 лет назад

      Thanks to indicate :),

    • @navdeepbains3481
      @navdeepbains3481 4 года назад

      uuuuuuuuuuuuuuuuuuuu rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyttttttttttttttttttttttttttttttttttttttt looooooooooooooooooooooooooooooooooooolllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

  • @mariya_6669
    @mariya_6669 4 года назад +10

    In angular 8:
    Import throwError from rxjs
    Import catchError from rxjs/operators
    Use catchError and throwError instead of catch and throw.
    Also use pipe when using catchError
    .pipe(catchError(this.errorHandler))
    Thank you codevolution...you have been great help

  • @technilicious5435
    @technilicious5435 3 года назад +2

    I love it when you say - Let me go over it one more time.... I really helps in understanding the concept better.... Thank you...

  • @simpleway2022
    @simpleway2022 6 лет назад +24

    import { Observable, throwError } from 'rxjs';
    import { catchError, } from 'rxjs/operators';
    then use throwError instead of Observable.throw

  • @idlevandal69
    @idlevandal69 6 лет назад +16

    For those using Angular 7 see Darwin Batres comment for updated code & imports then also change errorHandler() to the following:
    errorHandler(error: HttpErrorResponse) {
    return throwError(error.message || "Server Error!");
    }
    -Notice errorHandler() method doesn't use Observable.throw(error.message) but now uses just throwError(error.message)

  • @apprendrelefrancais5355
    @apprendrelefrancais5355 6 лет назад +5

    1) if there is error about Observable, then you need to modify import: import { Observable } from 'rxjs';
    2) if "catch" has error then you need to upgrad rxjs in terminal: npm i rxjs-compat

  • @sandman_theory
    @sandman_theory 6 лет назад +1

    Thank you !!!!!!!!!!!!! By far the best Angular Tutorial on RUclips. Period!

  • @crazy_coder
    @crazy_coder 6 лет назад +1

    your style to teach us is amazing very simple and understaning language that u use
    i watched many videos but ur videos are too good and also thanku for updating code in git for rxjs6
    THANKU SO MUCH SIR

  • @commentorsilensor3734
    @commentorsilensor3734 4 года назад

    Thank you very much for the video. I know it is frustrating that Angular keeps changing. I know some Angular 2. after seeing the change, I just start all over again on Angular 8. That is very frustrating. Thanks for the other video., Thanks for other people input to correct the problem.

  • @weicao4101
    @weicao4101 4 года назад

    Respect from China. Very useful and clear.

  • @arnavkumar6277
    @arnavkumar6277 4 года назад +1

    Observable.throw method is now deprecated. It is now replaced with throwError(error.message) where error is instance of HttpErrorResponse class. Same goes for catch. For catch use Observable.pipe(catchError(your method name)) and also import catchError and throwError.

  • @MayankGupta-kq5dm
    @MayankGupta-kq5dm 6 лет назад +19

    I think you only change Name Angular 7 but tutorial is angular 5

  • @programmersinsight7278
    @programmersinsight7278 6 лет назад +1

    To import the full Observable object you'd import it like this:
    import { Observable } from 'rxjs/Rx'
    Hopefully that helps!

  • @ketanvaidya3916
    @ketanvaidya3916 5 лет назад

    Loved your tutorials even being a beginner in angular I understood them quiet easily

  • @jeslinjoju7980
    @jeslinjoju7980 4 года назад

    Very good explanation. Really helpful. Thanks

  •  6 лет назад

    Great Tutorial Series - the best explanation i have seen so far. I've learned a lot. Thank you! And i with that i mean all lessons in this playlist!!!

  • @sonamohialdin3376
    @sonamohialdin3376 2 года назад

    So good teaching

  • @hoangngovan8217
    @hoangngovan8217 4 года назад

    Love it!, very easy to understanding. Thanks a lot.

  • @amanullahaman8750
    @amanullahaman8750 6 лет назад +1

    Very nice video with a good explanation. Please upload more videos.

  • @wayne_gakuo
    @wayne_gakuo 4 года назад +1

    Angular v8+
    import { Observable, throwError } from 'rxjs';
    import { catchError} from 'rxjs/operators';
    You need to pass the catchError operator through the pipe.
    ...
    .pipe(
    catchError(this.errorHandler));
    errorHandler(error: HttpErrorResponse) {
    return throwError (`Something went wrong: ${error.message}`);
    }
    PS: In the return statement of the errorHandler() function, I have used backticks instead of quotation marks, i.e template literals

  • @hemadrimedida1844
    @hemadrimedida1844 6 лет назад

    Very nice video with a good explanation. Please upload more videos on updated UI technologies.

  • @adnansheikh6776
    @adnansheikh6776 6 лет назад +1

    Hi,
    Thank you for posting this helpful guide.
    I'm doing authentication via API. The problem is i can't use subscribe with canActivate as it has Observable type. I can't change the Observable type as my whole functionality depends upon this type.
    So I have to use map instead of subscribe but then this authentication doesn't work. Please help me. I'm stuck on this from days.

  • @pavak7539
    @pavak7539 2 года назад +1

    you are jumping trains now.

    • @zenmarcky918
      @zenmarcky918 2 года назад

      do you fix the catch and throw?

  • @ikewabo
    @ikewabo 6 лет назад +6

    Can you do a series on REACT? After a few weeks with React, I must confess - I'M SOLD! No more Angular for me.

    • @JudenB2
      @JudenB2 6 лет назад

      is-it batter than angular ?

    • @vietson1610
      @vietson1610 6 лет назад

      I don't think so, nothing is the best, the same as program language.

    • @zoecarlibur
      @zoecarlibur 6 лет назад +5

      React is a cool tool, Especially for Start Ups, But when you're working on Big Enterprise applications with several moving parts & dependencies, There's no better choice than Angular. Not to mention the great support from Google.

    • @MithileshMusic92
      @MithileshMusic92 6 лет назад +1

      lot of companies are using React - fb , airbnb , netflix etc etc. so i think react handles scalability easily too. angular makes u think in the box only , with the restrictions it gives of using its own library of directives , pipes , services etc. React gives you freedom, to use whatever in the app structure you want depending on the requirements.

    • @ruhailahmad9418
      @ruhailahmad9418 6 лет назад

      I think you have not met with Redux yet.

  • @pratibhalovesu
    @pratibhalovesu 4 года назад +1

    Sir I'm a react guy got placed in angular project. I Got stuck in here

  • @devakireddy4983
    @devakireddy4983 4 года назад +1

    Hi sir when i write catch am not able to compile the code an getting the error as
    "Property 'catch' does not exist on type 'Observable'.
    "Can you please provide the solution for this

  • @navdeepbains3481
    @navdeepbains3481 4 года назад

    thanks sir for this amazing video

  • @gamerslife653
    @gamerslife653 4 года назад +1

    ERROR : Property 'catch' does not exist on type 'Observable

  • @zenmarcky918
    @zenmarcky918 2 года назад

    how do you fix the catch and throw?
    please help me Codevolution

  • @scrapifier
    @scrapifier 6 лет назад

    thanks you.Please Continue ...
    I send you good energy.

  • @jaypatel2471
    @jaypatel2471 10 месяцев назад

    @Codevolution sir we it would be great if you can provide videos on ANGULAR 17 !

  • @gustavomillanao8068
    @gustavomillanao8068 2 года назад +1

    it worked for me +1 sub

    • @zenmarcky918
      @zenmarcky918 2 года назад

      how do you fix the catch and throw?

  • @simonemeloni7967
    @simonemeloni7967 5 лет назад

    For catch error I have updated with command "npm i rxjs-compat", you need to restart visual studio code and, after you restart application with command "ng serve -o", and the problem will disappear.

  • @dorbenmoyal7639
    @dorbenmoyal7639 5 лет назад

    Hi Great lessons, is there any lesson about redux? and Effect?

  • @jayhey2577
    @jayhey2577 6 лет назад +2

    Didn't work for me, Just show the error in console, I think the new version of angular changed. he didn't user map, he used interface insted of map

  • @笨土豆
    @笨土豆 4 года назад

    Observable.throw has been replaced by throwError() in Angular 7

  • @mehmetakifalp
    @mehmetakifalp 6 лет назад

    good explanation, thanks!

  • @ayyappadasgb2163
    @ayyappadasgb2163 3 года назад

    RxJS v5.5.2 doesn't support 'catch()' as it is deprecated use 'catchError()' with Pipe() for this to work.

  • @SESURAJAPURAMARUL
    @SESURAJAPURAMARUL 6 лет назад +2

    You can acheive all these without importing anything from RxJS.
    as shown below
    this._employeeService.getEmployees().subscribe(
    data=> this.employees = data,
    err=> console.log(err.message)
    );
    I don't understand why there is a need for catching the error.

    • @akashchokshi2283
      @akashchokshi2283 5 лет назад

      The user doesn't know that they need to press F12 and open console to see the error. Like he said it won't be a good user experience.

  • @prakashk4878
    @prakashk4878 6 лет назад +1

    the catch operater is not working. How to solve it?

  • @Varunkumarmca
    @Varunkumarmca 6 лет назад

    You are awesome, thanks

  • @msh1996
    @msh1996 5 лет назад

    thanks

  • @binoysarker903
    @binoysarker903 6 лет назад

    in case of angular 6.1.4 use this to get the error
    this._employeeService.getEmployees().subscribe(data => {this.employees = data; }, error => console.log(error)
    );

  • @zenmarcky918
    @zenmarcky918 2 года назад

    how do you fix the catch and throw?

  • @veereshchinnu4641
    @veereshchinnu4641 4 года назад

    iam getting an error that 'catch' does not exist on type 'Observable' . please help me out!!..

  • @blackwhiteyang9533
    @blackwhiteyang9533 4 года назад

    rxjs 6.5.5 & Angular 10 is not avalible in this video,so grammar is different to use.

  • @joet_swbo101
    @joet_swbo101 6 лет назад

    How would I show the server message that I am passing through the BadRequest( string ) return value. I see it in Fiddler but can't seem to get a hold of it in my Angular service. I do get the appropriate error message, but that that one. Thanks

    • @joet_swbo101
      @joet_swbo101 6 лет назад

      Never mind, figured it out. Error.error.message.

  • @navdeepbains3481
    @navdeepbains3481 4 года назад

    hi sir please upload post,delete with server please this will be more informative forus

  • @nikitanarkhede5237
    @nikitanarkhede5237 5 лет назад

    Im getting Property 'catchError' does
    not exist on type 'Observable this error in angular8

  • @rajeshravichandran6102
    @rajeshravichandran6102 6 лет назад

    .get(this._url).pipe(catchError(this.errorHandler)) i m getting error at " .get " even after importing catchError and throwError----is that syntax error as Angular is updated to version 7...?

  • @sethbozz
    @sethbozz 6 лет назад +8

    Why don't you use the new API ? import { catchError } from 'rxjs/operators' ??!! This tuto seems kind of not fully accurate to me.

    • @JudenB2
      @JudenB2 6 лет назад

      what is the difference ?

    • @absolutedgefindout726
      @absolutedgefindout726 6 лет назад

      If you're following all along, you will not have this thinking, he explained in the beginning that this is based on Angular 5 but major principles remain the same across Angular 5, 6 and now 7.

    • @simpleway2022
      @simpleway2022 6 лет назад

      Thanks a lot.... I was becoming crazy trying to import catchError

  • @amitdubey5652
    @amitdubey5652 6 лет назад

    It's not working in angular 6 I tried lots of time but this example not working

  • @phanindrakumarpulletikurti
    @phanindrakumarpulletikurti 6 лет назад

    very nice

  • @punarvashumishra4172
    @punarvashumishra4172 4 года назад

    i am getting this error.can anyone help.
    Property 'catch' does not exist on type 'Observable'.ts(2339)

  • @songlee8456
    @songlee8456 6 лет назад

    Can you do ionic too?

  • @笨土豆
    @笨土豆 4 года назад

    Looks like .catch has been replaced by .pipe(catchError()) after angular 5.5.

  • @raghavendrajyante4200
    @raghavendrajyante4200 6 лет назад

    Sir please explain HttpInterceptor concept in Angular 6

  • @chagantisubhash
    @chagantisubhash 6 лет назад

    Great!!

  • @narisornsamukkarn1747
    @narisornsamukkarn1747 6 лет назад

    Great

  • @arunganesh9648
    @arunganesh9648 6 лет назад

    i get this below error,
    Module not found: Error: Can't resolve 'rxjs/add/observable/throw'

    • @animatedcartoons6301
      @animatedcartoons6301 5 лет назад

      same error for me Module not found: Error: Can't resolve 'rxjs/add/observable/catch'

  • @Gol_D_Roger_The_Pirate_King
    @Gol_D_Roger_The_Pirate_King 6 лет назад +3

    This is outdated please update to REAL Angular 6 pipe method error handling.

    • @Codevolution
      @Codevolution  6 лет назад

      Please watch video #31. And I hope you are excited about the wano arc!

    • @TheRonron1994
      @TheRonron1994 4 года назад

      ​@@Codevolution You should've at least updated the description for the updated fix or at least link the other video here without people asking for it.
      And in the video 31, you should've put timestamps. Disappointed.

  • @jayhey2577
    @jayhey2577 6 лет назад

    what happen to post !??? I didn't see it in the current tutorial? write a file insted of server side code

  • @toseefahmad9975
    @toseefahmad9975 5 лет назад

    TypeError: rxjs__WEBPACK_IMPORTED_MODULE_3__.Observable.throw is not a function this error is showing

  • @Committee-sw3yk
    @Committee-sw3yk 6 лет назад

    throws [object Object] error and doesn't shows list

  • @CppObjectOrientedProgrammer
    @CppObjectOrientedProgrammer 6 лет назад

    .catch doesn't work for me, I get Property catch does not exist on type. Tried googling around but I'm not sure what the problem is. I imported catch, but no luck.

  • @AmiraMahmoud7
    @AmiraMahmoud7 6 лет назад

    can't use catch and throw at all , always gives an error . Is there anyone with the same problem??

  • @MULAGURA
    @MULAGURA 6 лет назад

    what happens to .map( ) operator ?

  • @PiyushKumar-je6fk
    @PiyushKumar-je6fk 5 лет назад

    how to download link in error handlling video

  • @songlee8456
    @songlee8456 6 лет назад

    It looks like I'm going to move away from angular. map operator was easy to use. It's pointless to change it

  • @vivekjaiswal2422
    @vivekjaiswal2422 5 лет назад +2

    This video is very very out dated, please re-upload a video on this topic with latest changes.

  • @edmond1314
    @edmond1314 6 лет назад

    TypeError: rxjs__WEBPACK_IMPORTED_MODULE_2__.Observable.throwError is not a function

  • @Nampjg
    @Nampjg 4 года назад

    Please update this tutorial... Its incorrect !

  • @simpleway2022
    @simpleway2022 6 лет назад +2

    Good video but OUTDATED!

  • @mdaftabalam4919
    @mdaftabalam4919 6 лет назад

    I'm getting error in catch.Please reply me,

    • @punkkauz
      @punkkauz 5 лет назад

      did you solve?

  • @mahmoudabdelsattar8860
    @mahmoudabdelsattar8860 6 лет назад +2

    no no no not like that pls update ur tuts ,this is not updated angular>>>>>>>>>

    • @JFLABBERVILLE
      @JFLABBERVILLE 6 лет назад +1

      The man teaches everyone for free, he provides an update video at the end of the tutorial, the update info is very easy to find with clear guides yet people want him to use his precious time to rewrite this and re-film it for free for them with every update? I prefer to be grateful for his time and energy and am willing to do a little leg work on my own as well. The information isn't hard to find.

  • @muzamilahmed6396
    @muzamilahmed6396 5 лет назад

    You are running way fast in this video & there are not much examples.

  • @avantikagopi7514
    @avantikagopi7514 5 лет назад

    Your session is good but one request.. Change the color of ide to white cox it's not visible clearly in a mobile device.

  • @Dragosknight
    @Dragosknight 6 лет назад

    ERROR in src/app/employee.service.ts(14,49): error TS2339: Property 'catch' does not exist on type 'Observable'. I got this error. How to fix catch doesnot exists

    • @Codevolution
      @Codevolution  6 лет назад +1

      Please use catchError as that is the latest.

    • @rogerluces
      @rogerluces 6 лет назад

      Is not working!

  • @nikoszervo
    @nikoszervo 4 года назад

    I can create a better error handling mechanism in C than this. Wtf angular? You made so many awesome mechanisms and then you just throw us this shiity error handling? What about exceptions?