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

93
Views
Javascript desestructurando un nuevo objeto construido al llamar a una función
const {message, stack} = new Error('NOT GOOD'); logger.error({message, stack}); // <--- calling winston logger

Me pregunto si el código anterior se puede acortar en una sola línea, algo como:

 logger.error({message, stack} = new Error('NOT GOOD'));
ACTUALIZACIÓN: la razón por la que recibí esta pregunta:

Así es como formateo el registro de winston (en mecanografiado):

 // Creating file log message format const logFormat = printf(({ level, message, timestamp, stack }) => { return `${timestamp} ${level}: ${stack || message}`; });

Cuando llamo:

 logger.error(new Error('NOT GOOD'));

La salida es como tal:

 2022-01-28 12:12:12 error: undefined

Pero si yo:

 const {message, stack} = new Error('NOT GOOD'); logger.error({message, stack}); // <--- calling winston logger

Funciona según lo previsto. Muestra el message de error y la stack .

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!