Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is PHP exit()/die() equivalent in Node.js

Tags:

php

node.js

What is the PHP [die()]/(http://www.php.net/manual/de/function.die.php) equivalent in Node.js?

https://www.php.net/manual/de/function.exit.php

like image 852
Handsome Nerd Avatar asked Jan 17 '14 11:01

Handsome Nerd


2 Answers

process.exit() is the equivalent call.

like image 166
Uli Köhler Avatar answered Sep 28 '22 10:09

Uli Köhler


I would use throw. Throw will cause the current request at hand to end, and will not terminate the node process. You can catch that output using your error view.

throw new Error('your die message here'); 
like image 39
Anuraag Vaidya Avatar answered Sep 28 '22 10:09

Anuraag Vaidya