I
I
ivandao2019-09-09 18:00:25
Node.js
ivandao, 2019-09-09 18:00:25

Why can a Node.js script crash itself?

Why can a Node.js script crash itself? Ends execution without any errors and transfers control to the console.
How to catch this bastard?
Who faced?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Melodin, 2019-09-12
@melodyn

Put try catch at the top level and scatter a couple of console.logs at different steps with the results of calculations and explanatory text. More or less like this:

try {
  const result = do(); // какая-то "бизнес"-логика
  console.info('Запрос успешно выполнился с результатом: ', result);
  return result;
} catch (err) {
  console.error('Запрос упал со следующей ошибкой: ', err);
  return 'Захват человечества остановлен'
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question