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

230
Views
throw new Error() logs error message twice when using \n in message

I have a problem where the console will log an error twice when using \n in the error message.

Here is an example:

throw new Error("Vector lengths must be equal");

The code above results in :
Error: Vector lengths must be equal

As you can see this error message has printed once as expected.

throw new Error("Vector lengths must be equal" + "\nVector[0] = 1");

The code above results in :
Error: Vector lengths must be equal
Vector[0] = 1
Error: Vector lengths must be equal
Vector[0] = 1

Here, I have added \n in the error message to create a break in the error message for increased readability, but as you can see it prints the error message twice which is unexpected and repetitive.

Please advise me in any way on how I can work around or even fix this problem.

about 4 years ago · Juan Pablo Isaza
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!