Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Is "catch(console.error)" a valid way of catching Promise rejections?

Let's say I have a Promise and catch the error like so:

fetch().then(data => {
  console.log(data);
}).catch(console.error);

Is this a valid code? I've seen people do this, but I don't understand how catch(console.error) works.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Yes, if you just want to log the error and otherwise ignore it, that works.

.catch expects you to pass it in a function, and if the promise rejects, that function will be called with the rejection value. Often you'll create a new function with custom logic and pass that in, but it's fine to pass in a function that already exists, such as console.error.

about 4 years ago · Juan Pablo Isaza Report

0

yes it's all right.It's same as passing error object and then logging it in console.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!