New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apperror

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apperror - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

21

apperror.js

@@ -9,4 +9,2 @@ /* vim: set softtabstop=4 ts=4 sw=4 expandtab tw=120 syntax=javascript: */

var _ = require('lodash');
var DEFAULT_LOGGER = console;

@@ -17,3 +15,3 @@

opts = opts || {};
if (_.isString(opts)) { opts = {message: opts}; }
if (typeof opts === 'string') { opts = {message: opts}; }
this.message = opts.message || 'An error occurred.';

@@ -24,4 +22,4 @@ this.data = opts.data || '';

this.isAppError = true;
this.logError = _.isUndefined(opts.logError) && true || opts.logError;
this.captureStack = _.isUndefined(opts.captureStack) && true || opts.captureStack;
this.logError = typeof opts.logError !== 'boolean' && true || opts.logError;
this.captureStack = typeof opts.captureStack !== 'boolean' && true || opts.captureStack;
if (this.captureStack) {

@@ -46,7 +44,6 @@ Error.captureStackTrace(this, (context || AppError));

logger = logger || this.DEFAULT_LOGGER || DEFAULT_LOGGER;
var logged = _.find(this._logged, {logger: logger});
if (!this.logError || this.logError && logged) {
if (typeof logger.error !== 'function' || !this.logError || this.logError || this._logged.length) {
return this;
}
this._logged.push({logger: logger});
this._logged.push({logger});
logger.error(this.toJSON());

@@ -61,9 +58,9 @@ var stack = this.stack;

if (!(this instanceof Error)) { return new CustomError(msgOrOpts, code, data); }
var opts = _.extend({}, defaults);
if (_.isObject(msgOrOpts)) {
var opts = Object.assign({}, defaults);
if (msgOrOpts && typeof msgOrOpts === 'object') {
opts.message = msgOrOpts.message || msgOrOpts.msg || opts.message || opts.msg;
opts.code = msgOrOpts.code || msgOrOpts.status || msgOrOpts.statusCode || opts.code || opts.status || opts.statusCode;
opts.data = msgOrOpts.data || opts.data;
if (!_.isUndefined(msgOrOpts.captureStack)) { opts.captureStack = msgOrOpts.captureStack; }
if (!_.isUndefined(msgOrOpts.logError)) { opts.logError = msgOrOpts.logError; }
if (typeof msgOrOpts.captureStack === 'boolean') { opts.captureStack = msgOrOpts.captureStack; }
if (typeof msgOrOpts.logError === 'boolean') { opts.logError = msgOrOpts.logError; }
} else {

@@ -70,0 +67,0 @@ opts.message = msgOrOpts || opts.message || opts.msg;

@@ -5,3 +5,3 @@ {

"repository": "https://github.com/gradecam/nodejs-apperror",
"version": "1.3.1",
"version": "1.3.2",
"description": "A customizable application error generator.",

@@ -11,6 +11,3 @@ "main": "apperror.js",

"author": "Jarom Loveridge <jaroml@gradecam.com>",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.11"
}
"license": "MIT"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc