<commit_before>var loopback = require('loopback');
var boot = require('loopback-boot');

//Initialize Logger
var log4js = require('log4js');
log4js.configure('server/log4js_configuration.json', {});
var logger = log4js.getLogger('app');

var app = module.exports = loopback();

app.log4js = log4js;


app.start = function() {
  // start the web server
  return app.listen(function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
    app.log4js.getLogger('app').debug('App started');
  });
};




// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
  if (err) throw err;

  // start the server if `$ node server.js`
  if (require.main === module)
    app.start();
});

app.get('remoting').errorHandler = {
  handler: function(err, req, res, defaultHandler) {
  	err = app.buildError(err);
    var ret = {};
    ret.message = 'Unexpected Error occured on server when processing request!';
    ret.status = err.statusCode;
    app.log4js.getLogger('app').error('Sever Internal Error : ' + err.message);
    res.status(err.statusCode).json(ret);

    // send the error back to the original handlero
    defaultHandler(err);<commit_msg>Resolve Issue with REST error handler<commit_after>var loopback = require('loopback');
var boot = require('loopback-boot');

//Initialize Logger
var log4js = require('log4js');
log4js.configure('server/log4js_configuration.json', {});
var logger = log4js.getLogger('app');

var app = module.exports = loopback();

app.log4js = log4js;


app.start = function() {
  // start the web server
  return app.listen(function() {
    app.emit('started');
    console.log('Web server listening at: %s', app.get('url'));
    app.log4js.getLogger('app').debug('App started');
  });
};




// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
  if (err) throw err;

  // start the server if `$ node server.js`
  if (require.main === module)
    app.start();
});

app.get('remoting').errorHandler = {
  handler: function(err, req, res, defaultHandler) {
  	err = app.buildError(err);
    var ret = {};
    ret.message = 'Sever Internal Error : ' + err.message;
    ret.status = err.statusCode;
    app.log4js.getLogger('app').error('Sever Internal Error : ' + err.message);
    res.status(err.statusCode).json(ret);

    // End here no need to use Default Error Handler

{'fraction_non_alphanumeric': 0.15477582846003898, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 3.9441233140655108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6491519', 'n_tokens_mistral': 818, 'n_tokens_neox': 798, 'n_words': 214}