Tuesday, 25 April 2017

How to run a function when nodeapp returns error

I want to be able throw a function when my node app returns error

Let's say I have a simple node app

var express= require('express');
var app = express();
var http = require('http');

app.get('/', function(req, res){
res.send('hello')
})

app.listen(2500);

if there is an error while running the app, it might be related to the port or i might not have a proper node package module installed i just want it to run a function.. how do i do that?

I want it to console.log('node crashed') for example



via Can Unbay

No comments:

Post a Comment