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

214
Views
Discordjs no pudo detectar un DiscordAPIError

Básicamente, el problema es que incluso si envuelvo el código que causa el error al intentar atrapar, el error aún detiene el código, aquí está mi código.

 // snip try{ // get user using id "does-not-exist", which does not exist // code stops when fetching user client.users.fetch('does-not-exist').then(function (user) { user.send('hello'); }); }catch(err){ console.error('message could not be sent'); }

¿Por qué mi código se detiene incluso si lo envuelvo con try catch?

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

0

try/catch debe usarse en combinación con async/await . Si desea utilizar el método then/catch síncrono, utilice la devolución de llamada .catch() respectiva.

 client.users.fetch('does-not-exist') .then(function (user) { user.send('hello'); }) .catch(err => /* error handle */);

Si desea ignorar el error, anule el error.

 .catch(_ => null);

Cómo se vería con async await

 try { const user = await client.users.fetch('does-not-exist') } catch (err) { /* Handle Error */ }
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!