Why is `.catch(err => console.error(err))` discouraged?

前端 未结 5 1097
别跟我提以往
别跟我提以往 2021-01-30 19:47

I\'m using promises and have code that looks like the following:

function getStuff() { 
  return fetchStuff().then(stuff => 
    process(stuff)
  ).catch(err          


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 20:24

    error is much too generic, it is a catch all but there are only so many things that the operation would fail with, error is everything errorSomethingSpecific gives granularity

提交回复
热议问题