Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@feathersjs/errors

Package Overview
Dependencies
Maintainers
4
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/errors - npm Package Compare versions

Comparing version 4.5.11 to 5.0.0-beta.0

lib/index.d.ts

30

CHANGELOG.md

@@ -6,3 +6,3 @@ # Change Log

## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05)
# [5.0.0-beta.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.1...v5.0.0-beta.0) (2021-03-28)

@@ -12,3 +12,3 @@

* **typescript:** Fix `data` property definition in @feathersjs/errors ([#2018](https://github.com/feathersjs/feathers/issues/2018)) ([ef1398c](https://github.com/feathersjs/feathers/commit/ef1398cd5b19efa50929e8c9511ca5684a18997f))
* Update Grant usage and other dependencies ([#2264](https://github.com/feathersjs/feathers/issues/2264)) ([7b0f8fa](https://github.com/feathersjs/feathers/commit/7b0f8fad252419ed0ad0bf259cdf3104d322ab60))

@@ -19,2 +19,28 @@

# [5.0.0-pre.1](https://github.com/feathersjs/feathers/compare/v4.5.11...v5.0.0-pre.1) (2020-12-17)
# [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19)
### Bug Fixes
* **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758))
# [5.0.0-pre.0](https://github.com/feathersjs/feathers/compare/v4.5.4...v5.0.0-pre.0) (2020-05-19)
### Bug Fixes
* **errors:** Format package.json with spaces ([cbd31c1](https://github.com/feathersjs/feathers/commit/cbd31c10c2c574de63d6ca5e55dbfb73a5fdd758))
* **typescript:** Fix `data` property definition in @feathersjs/errors ([#2018](https://github.com/feathersjs/feathers/issues/2018)) ([ef1398c](https://github.com/feathersjs/feathers/commit/ef1398cd5b19efa50929e8c9511ca5684a18997f))
## [4.5.11](https://github.com/feathersjs/feathers/compare/v4.5.10...v4.5.11) (2020-12-05)
**Note:** Version bump only for package @feathersjs/errors
## [4.5.10](https://github.com/feathersjs/feathers/compare/v4.5.9...v4.5.10) (2020-11-08)

@@ -21,0 +47,0 @@

403

lib/index.js

@@ -1,258 +0,221 @@

const debug = require('debug')('@feathersjs/errors');
function FeathersError (msg, name, code, className, data) {
msg = msg || 'Error';
let errors;
let message;
let newData;
if (msg instanceof Error) {
message = msg.message || 'Error';
// NOTE (EK): This is typically to handle validation errors
if (msg.errors) {
errors = msg.errors;
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.convert = exports.errors = exports.Unavailable = exports.BadGateway = exports.NotImplemented = exports.GeneralError = exports.TooManyRequests = exports.Unprocessable = exports.LengthRequired = exports.Gone = exports.Conflict = exports.Timeout = exports.NotAcceptable = exports.MethodNotAllowed = exports.NotFound = exports.Forbidden = exports.PaymentError = exports.NotAuthenticated = exports.BadRequest = exports.FeathersError = void 0;
class FeathersError extends Error {
constructor(err, name, code, className, _data) {
let msg = typeof err === 'string' ? err : 'Error';
const properties = {
name,
code,
className,
type: 'FeathersError'
};
if (Array.isArray(_data)) {
properties.data = _data;
}
else if (typeof err === 'object' || _data !== undefined) {
const _a = typeof err === 'object' ? err : _data, { message, errors } = _a, rest = __rest(_a, ["message", "errors"]);
msg = message || msg;
properties.errors = errors;
properties.data = rest;
}
super(msg);
Object.assign(this, properties);
}
} else if (typeof msg === 'object') { // Support plain old objects
message = msg.message || 'Error';
data = msg;
} else { // message is just a string
message = msg;
}
if (data) {
// NOTE(EK): To make sure that we are not messing
// with immutable data, just make a copy.
// https://github.com/feathersjs/errors/issues/19
newData = JSON.parse(JSON.stringify(data));
if (newData.errors) {
errors = newData.errors;
delete newData.errors;
} else if (data.errors) {
// The errors property from data could be
// stripped away while cloning resulting newData not to have it
// For example: when cloning arrays this property
errors = JSON.parse(JSON.stringify(data.errors));
toJSON() {
const result = {
name: this.name,
message: this.message,
code: this.code,
className: this.className
};
if (this.data !== undefined) {
result.data = this.data;
}
if (this.errors !== undefined) {
result.errors = this.errors;
}
return result;
}
}
// NOTE (EK): Babel doesn't support this so
// we have to pass in the class name manually.
// this.name = this.constructor.name;
this.type = 'FeathersError';
this.name = name;
this.message = message;
this.code = code;
this.className = className;
this.data = newData;
this.errors = errors || {};
debug(`${this.name}(${this.code}): ${this.message}`);
debug(this.errors);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, FeathersError);
} else {
this.stack = (new Error()).stack;
}
}
function inheritsFrom (Child, Parent) {
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
exports.FeathersError = FeathersError;
class BadRequest extends FeathersError {
constructor(message, data) {
super(message, 'BadRequest', 400, 'bad-request', data);
}
}
inheritsFrom(FeathersError, Error);
// NOTE (EK): A little hack to get around `message` not
// being included in the default toJSON call.
Object.defineProperty(FeathersError.prototype, 'toJSON', {
value: function () {
return {
name: this.name,
message: this.message,
code: this.code,
className: this.className,
data: this.data,
errors: this.errors
};
}
});
// 400 - Bad Request
function BadRequest (message, data) {
FeathersError.call(this, message, 'BadRequest', 400, 'bad-request', data);
}
inheritsFrom(BadRequest, FeathersError);
exports.BadRequest = BadRequest;
// 401 - Not Authenticated
function NotAuthenticated (message, data) {
FeathersError.call(this, message, 'NotAuthenticated', 401, 'not-authenticated', data);
class NotAuthenticated extends FeathersError {
constructor(message, data) {
super(message, 'NotAuthenticated', 401, 'not-authenticated', data);
}
}
inheritsFrom(NotAuthenticated, FeathersError);
exports.NotAuthenticated = NotAuthenticated;
// 402 - Payment Error
function PaymentError (message, data) {
FeathersError.call(this, message, 'PaymentError', 402, 'payment-error', data);
class PaymentError extends FeathersError {
constructor(message, data) {
super(message, 'PaymentError', 402, 'payment-error', data);
}
}
inheritsFrom(PaymentError, FeathersError);
exports.PaymentError = PaymentError;
// 403 - Forbidden
function Forbidden (message, data) {
FeathersError.call(this, message, 'Forbidden', 403, 'forbidden', data);
class Forbidden extends FeathersError {
constructor(message, data) {
super(message, 'Forbidden', 403, 'forbidden', data);
}
}
inheritsFrom(Forbidden, FeathersError);
exports.Forbidden = Forbidden;
// 404 - Not Found
function NotFound (message, data) {
FeathersError.call(this, message, 'NotFound', 404, 'not-found', data);
class NotFound extends FeathersError {
constructor(message, data) {
super(message, 'NotFound', 404, 'not-found', data);
}
}
inheritsFrom(NotFound, FeathersError);
exports.NotFound = NotFound;
// 405 - Method Not Allowed
function MethodNotAllowed (message, data) {
FeathersError.call(this, message, 'MethodNotAllowed', 405, 'method-not-allowed', data);
class MethodNotAllowed extends FeathersError {
constructor(message, data) {
super(message, 'MethodNotAllowed', 405, 'method-not-allowed', data);
}
}
inheritsFrom(MethodNotAllowed, FeathersError);
exports.MethodNotAllowed = MethodNotAllowed;
// 406 - Not Acceptable
function NotAcceptable (message, data) {
FeathersError.call(this, message, 'NotAcceptable', 406, 'not-acceptable', data);
class NotAcceptable extends FeathersError {
constructor(message, data) {
super(message, 'NotAcceptable', 406, 'not-acceptable', data);
}
}
inheritsFrom(NotAcceptable, FeathersError);
exports.NotAcceptable = NotAcceptable;
// 408 - Timeout
function Timeout (message, data) {
FeathersError.call(this, message, 'Timeout', 408, 'timeout', data);
class Timeout extends FeathersError {
constructor(message, data) {
super(message, 'Timeout', 408, 'timeout', data);
}
}
inheritsFrom(Timeout, FeathersError);
exports.Timeout = Timeout;
// 409 - Conflict
function Conflict (message, data) {
FeathersError.call(this, message, 'Conflict', 409, 'conflict', data);
class Conflict extends FeathersError {
constructor(message, data) {
super(message, 'Conflict', 409, 'conflict', data);
}
}
inheritsFrom(Conflict, FeathersError);
exports.Conflict = Conflict;
// 410 - Gone
function Gone (message, data) {
FeathersError(this, message, 'Gone', 410, 'gone', data);
class Gone extends FeathersError {
constructor(message, data) {
super(message, 'Gone', 410, 'gone', data);
}
}
inheritsFrom(Gone, FeathersError);
exports.Gone = Gone;
// 411 - Length Required
function LengthRequired (message, data) {
FeathersError.call(this, message, 'LengthRequired', 411, 'length-required', data);
class LengthRequired extends FeathersError {
constructor(message, data) {
super(message, 'LengthRequired', 411, 'length-required', data);
}
}
inheritsFrom(LengthRequired, FeathersError);
exports.LengthRequired = LengthRequired;
// 422 Unprocessable
function Unprocessable (message, data) {
FeathersError.call(this, message, 'Unprocessable', 422, 'unprocessable', data);
class Unprocessable extends FeathersError {
constructor(message, data) {
super(message, 'Unprocessable', 422, 'unprocessable', data);
}
}
inheritsFrom(Unprocessable, FeathersError);
exports.Unprocessable = Unprocessable;
// 429 Too Many Requests
function TooManyRequests (message, data) {
FeathersError.call(this, message, 'TooManyRequests', 429, 'too-many-requests', data);
class TooManyRequests extends FeathersError {
constructor(message, data) {
super(message, 'TooManyRequests', 429, 'too-many-requests', data);
}
}
inheritsFrom(TooManyRequests, FeathersError);
exports.TooManyRequests = TooManyRequests;
// 500 - General Error
function GeneralError (message, data) {
FeathersError.call(this, message, 'GeneralError', 500, 'general-error', data);
class GeneralError extends FeathersError {
constructor(message, data) {
super(message, 'GeneralError', 500, 'general-error', data);
}
}
inheritsFrom(GeneralError, FeathersError);
exports.GeneralError = GeneralError;
// 501 - Not Implemented
function NotImplemented (message, data) {
FeathersError.call(this, message, 'NotImplemented', 501, 'not-implemented', data);
class NotImplemented extends FeathersError {
constructor(message, data) {
super(message, 'NotImplemented', 501, 'not-implemented', data);
}
}
inheritsFrom(NotImplemented, FeathersError);
exports.NotImplemented = NotImplemented;
// 502 - Bad Gateway
function BadGateway (message, data) {
FeathersError.call(this, message, 'BadGateway', 502, 'bad-gateway', data);
class BadGateway extends FeathersError {
constructor(message, data) {
super(message, 'BadGateway', 502, 'bad-gateway', data);
}
}
inheritsFrom(BadGateway, FeathersError);
exports.BadGateway = BadGateway;
// 503 - Unavailable
function Unavailable (message, data) {
FeathersError.call(this, message, 'Unavailable', 503, 'unavailable', data);
class Unavailable extends FeathersError {
constructor(message, data) {
super(message, 'Unavailable', 503, 'unavailable', data);
}
}
inheritsFrom(Unavailable, FeathersError);
const errors = {
FeathersError,
BadRequest,
NotAuthenticated,
PaymentError,
Forbidden,
NotFound,
MethodNotAllowed,
NotAcceptable,
Timeout,
Conflict,
Gone,
LengthRequired,
Unprocessable,
TooManyRequests,
GeneralError,
NotImplemented,
BadGateway,
Unavailable,
400: BadRequest,
401: NotAuthenticated,
402: PaymentError,
403: Forbidden,
404: NotFound,
405: MethodNotAllowed,
406: NotAcceptable,
408: Timeout,
409: Conflict,
410: Gone,
411: LengthRequired,
422: Unprocessable,
429: TooManyRequests,
500: GeneralError,
501: NotImplemented,
502: BadGateway,
503: Unavailable
exports.Unavailable = Unavailable;
exports.errors = {
FeathersError,
BadRequest,
NotAuthenticated,
PaymentError,
Forbidden,
NotFound,
MethodNotAllowed,
NotAcceptable,
Timeout,
Conflict,
LengthRequired,
Unprocessable,
TooManyRequests,
GeneralError,
NotImplemented,
BadGateway,
Unavailable,
400: BadRequest,
401: NotAuthenticated,
402: PaymentError,
403: Forbidden,
404: NotFound,
405: MethodNotAllowed,
406: NotAcceptable,
408: Timeout,
409: Conflict,
410: Gone,
411: LengthRequired,
422: Unprocessable,
429: TooManyRequests,
500: GeneralError,
501: NotImplemented,
502: BadGateway,
503: Unavailable
};
function convert (error) {
if (!error) {
return error;
}
const FeathersError = errors[error.name];
const result = FeathersError
? new FeathersError(error.message, error.data)
: new Error(error.message || error);
if (typeof error === 'object') {
Object.assign(result, error);
}
return result;
function convert(error) {
if (!error) {
return error;
}
const FeathersError = exports.errors[error.name];
const result = FeathersError
? new FeathersError(error.message, error.data)
: new Error(error.message || error);
if (typeof error === 'object') {
Object.assign(result, error);
}
return result;
}
module.exports = Object.assign({ convert }, errors);
exports.convert = convert;
//# sourceMappingURL=index.js.map
{
"name": "@feathersjs/errors",
"description": "Common error types for Feathers apps",
"version": "4.5.11",
"homepage": "https://feathersjs.com",
"main": "lib/index",
"types": "index.d.ts",
"keywords": [
"feathers",
"feathers-plugin"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/feathersjs/feathers.git"
},
"author": {
"name": "Feathers contributors",
"email": "hello@feathersjs.com",
"url": "https://feathersjs.com"
},
"contributors": [],
"bugs": {
"url": "https://github.com/feathersjs/feathers/issues"
},
"engines": {
"node": ">= 10"
},
"directories": {
"lib": "lib"
},
"files": [
"CHANGELOG.md",
"LICENSE",
"README.md",
"src/**",
"lib/**",
"*.d.ts",
"*.js"
],
"scripts": {
"test": "mocha --config ../../.mocharc.json"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"debug": "^4.3.1"
},
"devDependencies": {
"@feathersjs/feathers": "^4.5.11",
"express": "^4.17.1",
"mocha": "^8.2.1"
},
"gitHead": "de0526849eb36ab6ef19ef1764e0d9e0a6ccbd81"
"name": "@feathersjs/errors",
"description": "Common error types for Feathers apps",
"version": "5.0.0-beta.0",
"homepage": "https://feathersjs.com",
"main": "lib/",
"types": "lib/",
"keywords": [
"feathers",
"feathers-plugin"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/feathersjs/feathers.git"
},
"author": {
"name": "Feathers contributors",
"email": "hello@feathersjs.com",
"url": "https://feathersjs.com"
},
"contributors": [],
"bugs": {
"url": "https://github.com/feathersjs/feathers/issues"
},
"engines": {
"node": ">= 12"
},
"directories": {
"lib": "lib"
},
"scripts": {
"prepublish": "npm run compile",
"compile": "shx rm -rf lib/ && tsc",
"test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
},
"publishConfig": {
"access": "public"
},
"files": [
"CHANGELOG.md",
"LICENSE",
"README.md",
"src/**",
"lib/**",
"*.d.ts",
"*.js"
],
"devDependencies": {
"@feathersjs/feathers": "^5.0.0-beta.0",
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.37",
"mocha": "^8.3.2",
"shx": "^0.3.3",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
},
"gitHead": "3b953f85cc1c2184a032bebac302f8de8a2f0d4d"
}

Sorry, the diff of this file is not supported yet

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