Socket
Socket
Sign inDemoInstall

@feathersjs/errors

Package Overview
Dependencies
Maintainers
4
Versions
115
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 5.0.0-pre.22 to 5.0.0-pre.23

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06)
**Note:** Version bump only for package @feathersjs/errors
# [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)

@@ -8,0 +16,0 @@

12

package.json
{
"name": "@feathersjs/errors",
"description": "Common error types for Feathers apps",
"version": "5.0.0-pre.22",
"version": "5.0.0-pre.23",
"homepage": "https://feathersjs.com",

@@ -51,11 +51,11 @@ "main": "lib/",

"devDependencies": {
"@feathersjs/feathers": "^5.0.0-pre.22",
"@feathersjs/feathers": "^5.0.0-pre.23",
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.31",
"@types/node": "^17.0.40",
"mocha": "^10.0.0",
"shx": "^0.3.4",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
},
"gitHead": "e452e02063e6d8943a9cae2315ab585bc4f82fb6"
"gitHead": "a60910bd730b88053ca6648337095f1ca1e3b39f"
}
export interface FeathersErrorJSON {
name: string;
message: string;
code: number;
className: string;
data?: any;
errors?: any;
name: string
message: string
code: number
className: string
data?: any
errors?: any
}
export type DynamicError = Error & { [key: string]: any };
export type ErrorMessage = string | DynamicError | { [key: string]: any } | any[];
export type DynamicError = Error & { [key: string]: any }
export type ErrorMessage = string | DynamicError | { [key: string]: any } | any[]
interface ErrorProperties extends Omit<FeathersErrorJSON, 'message'> {
type: string;
type: string
}
export class FeathersError extends Error {
readonly type: string;
readonly code: number;
readonly className: string;
readonly data: any;
readonly errors: any;
readonly type: string
readonly code: number
readonly className: string
readonly data: any
readonly errors: any
constructor (err: ErrorMessage, name: string, code: number, className: string, _data: any) {
let msg = typeof err === 'string' ? err : 'Error';
constructor(err: ErrorMessage, name: string, code: number, className: string, _data: any) {
let msg = typeof err === 'string' ? err : 'Error'
const properties: ErrorProperties = {

@@ -31,19 +31,19 @@ name,

type: 'FeathersError'
};
}
if (Array.isArray(_data)) {
properties.data = _data;
properties.data = _data
} else if (typeof err === 'object' || _data !== undefined) {
const { message, errors, ...rest } = typeof err === 'object' ? err : _data;
const { message, errors, ...rest } = typeof err === 'object' ? err : _data
msg = message || msg;
properties.errors = errors;
properties.data = rest;
msg = message || msg
properties.errors = errors
properties.data = rest
}
super(msg);
Object.assign(this, properties);
super(msg)
Object.assign(this, properties)
}
toJSON () {
toJSON() {
const result: FeathersErrorJSON = {

@@ -54,13 +54,13 @@ name: this.name,

className: this.className
};
}
if (this.data !== undefined) {
result.data = this.data;
result.data = this.data
}
if (this.errors !== undefined) {
result.errors = this.errors;
result.errors = this.errors
}
return result;
return result
}

@@ -70,4 +70,4 @@ }

export class BadRequest extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'BadRequest', 400, 'bad-request', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'BadRequest', 400, 'bad-request', data)
}

@@ -77,5 +77,5 @@ }

// 401 - Not Authenticated
export class NotAuthenticated extends FeathersError{
constructor (message?: ErrorMessage, data?: any) {
super(message, 'NotAuthenticated', 401, 'not-authenticated', data);
export class NotAuthenticated extends FeathersError {
constructor(message?: ErrorMessage, data?: any) {
super(message, 'NotAuthenticated', 401, 'not-authenticated', data)
}

@@ -86,4 +86,4 @@ }

export class PaymentError extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'PaymentError', 402, 'payment-error', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'PaymentError', 402, 'payment-error', data)
}

@@ -94,4 +94,4 @@ }

export class Forbidden extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Forbidden', 403, 'forbidden', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Forbidden', 403, 'forbidden', data)
}

@@ -102,4 +102,4 @@ }

export class NotFound extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'NotFound', 404, 'not-found', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'NotFound', 404, 'not-found', data)
}

@@ -110,4 +110,4 @@ }

export class MethodNotAllowed extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'MethodNotAllowed', 405, 'method-not-allowed', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'MethodNotAllowed', 405, 'method-not-allowed', data)
}

@@ -118,4 +118,4 @@ }

export class NotAcceptable extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'NotAcceptable', 406, 'not-acceptable', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'NotAcceptable', 406, 'not-acceptable', data)
}

@@ -126,4 +126,4 @@ }

export class Timeout extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Timeout', 408, 'timeout', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Timeout', 408, 'timeout', data)
}

@@ -134,4 +134,4 @@ }

export class Conflict extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Conflict', 409, 'conflict', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Conflict', 409, 'conflict', data)
}

@@ -142,4 +142,4 @@ }

export class Gone extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Gone', 410, 'gone', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Gone', 410, 'gone', data)
}

@@ -150,4 +150,4 @@ }

export class LengthRequired extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'LengthRequired', 411, 'length-required', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'LengthRequired', 411, 'length-required', data)
}

@@ -158,4 +158,4 @@ }

export class Unprocessable extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Unprocessable', 422, 'unprocessable', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Unprocessable', 422, 'unprocessable', data)
}

@@ -166,4 +166,4 @@ }

export class TooManyRequests extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'TooManyRequests', 429, 'too-many-requests', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'TooManyRequests', 429, 'too-many-requests', data)
}

@@ -174,4 +174,4 @@ }

export class GeneralError extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'GeneralError', 500, 'general-error', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'GeneralError', 500, 'general-error', data)
}

@@ -182,4 +182,4 @@ }

export class NotImplemented extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'NotImplemented', 501, 'not-implemented', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'NotImplemented', 501, 'not-implemented', data)
}

@@ -190,4 +190,4 @@ }

export class BadGateway extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'BadGateway', 502, 'bad-gateway', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'BadGateway', 502, 'bad-gateway', data)
}

@@ -198,4 +198,4 @@ }

export class Unavailable extends FeathersError {
constructor (message?: ErrorMessage, data?: any) {
super(message, 'Unavailable', 503, 'unavailable', data);
constructor(message?: ErrorMessage, data?: any) {
super(message, 'Unavailable', 503, 'unavailable', data)
}

@@ -205,35 +205,35 @@ }

export interface Errors {
FeathersError: FeathersError;
BadRequest: BadRequest;
NotAuthenticated: NotAuthenticated;
PaymentError: PaymentError;
Forbidden: Forbidden;
NotFound: NotFound;
MethodNotAllowed: MethodNotAllowed;
NotAcceptable: NotAcceptable;
Timeout: Timeout;
Conflict: Conflict;
LengthRequired: LengthRequired;
Unprocessable: Unprocessable;
TooManyRequests: TooManyRequests;
GeneralError: GeneralError;
NotImplemented: NotImplemented;
BadGateway: BadGateway;
Unavailable: Unavailable;
400: BadRequest;
401: NotAuthenticated;
402: PaymentError;
403: Forbidden;
404: NotFound;
405: MethodNotAllowed;
406: NotAcceptable;
408: Timeout;
409: Conflict;
411: LengthRequired;
422: Unprocessable;
429: TooManyRequests;
500: GeneralError;
501: NotImplemented;
502: BadGateway;
503: Unavailable;
FeathersError: FeathersError
BadRequest: BadRequest
NotAuthenticated: NotAuthenticated
PaymentError: PaymentError
Forbidden: Forbidden
NotFound: NotFound
MethodNotAllowed: MethodNotAllowed
NotAcceptable: NotAcceptable
Timeout: Timeout
Conflict: Conflict
LengthRequired: LengthRequired
Unprocessable: Unprocessable
TooManyRequests: TooManyRequests
GeneralError: GeneralError
NotImplemented: NotImplemented
BadGateway: BadGateway
Unavailable: Unavailable
400: BadRequest
401: NotAuthenticated
402: PaymentError
403: Forbidden
404: NotFound
405: MethodNotAllowed
406: NotAcceptable
408: Timeout
409: Conflict
411: LengthRequired
422: Unprocessable
429: TooManyRequests
500: GeneralError
501: NotImplemented
502: BadGateway
503: Unavailable
}

@@ -278,17 +278,17 @@

export function convert (error: any) {
export function convert(error: any) {
if (!error) {
return error;
return error
}
const FeathersError = (errors as any)[error.name];
const FeathersError = (errors as any)[error.name]
const result = FeathersError
? new FeathersError(error.message, error.data)
: new Error(error.message || error);
: new Error(error.message || error)
if (typeof error === 'object') {
Object.assign(result, error);
Object.assign(result, error)
}
return result;
return result
}

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