Socket
Socket
Sign inDemoInstall

@kamalyb/errors

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kamalyb/errors - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

29

dist/index.d.ts

@@ -0,3 +1,3 @@

import { ExtendableError } from 'extendable-error';
import { ValidationErrorItem } from 'joi';
import { ExtendableError } from 'extendable-error';

@@ -9,6 +9,5 @@ interface ErrorProps {

}
type CustomErrorParam = string | string[] | ErrorProps | ErrorProps[] | Array<string | ErrorProps>;
type CustomErrorParam = string | ErrorProps | Array<string | ErrorProps>;
type ErrorStatus = 400 | 401 | 403 | 404 | 409 | 422 | 429 | 500;
declare const msg: (param: ValidationErrorItem[] | CustomErrorParam, concat?: boolean) => string;
declare const messages: {

@@ -21,3 +20,3 @@ 403: string;

};
declare const setdefaultmessage: (t: Partial<typeof messages>) => void;
declare const setmessages: (t: Partial<typeof messages>) => void;
declare const ERRORS: readonly ["BadRequestError", "ForbiddenError", "InternalServerError", "JoiValidationError", "NotAuthorizedError", "NotFoundError", "RateLimitError", "UnprocessableEntityError", "CustomValidationError", "ConflictError", "SomeError"];

@@ -48,6 +47,2 @@ type ICustomError = (typeof ERRORS)[number];

readonly name = "ForbiddenError";
/**
*
* @default thou shalt not
*/
constructor(message?: string);

@@ -63,6 +58,2 @@ serialize(): {

readonly name = "InternalServerError";
/**
*
* @default internal server error
*/
constructor(message?: string);

@@ -89,6 +80,2 @@ serialize(): {

private readonly param;
/**
*
* @default you shall not pass
*/
constructor(message?: string);

@@ -102,6 +89,2 @@ constructor(props?: ErrorProps);

readonly name = "NotFoundError";
/**
*
* @default not found
*/
constructor(message?: string);

@@ -117,6 +100,2 @@ serialize(): {

readonly name = "RateLimitError";
/**
*
* @default too many requests. please try again later
*/
constructor(message?: string);

@@ -165,2 +144,2 @@ serialize(): {

export { BadRequestError, ConflictError, CustomError, CustomErrorParam, ERRORS, ErrorProps, ErrorStatus, ForbiddenError, ICustomError, InternalServerError, JoiValidationError, NotAuthorizedError, NotFoundError, RateLimitError, SomeError, UnprocessableEntityError, ValidationError, messages, msg, setdefaultmessage };
export { BadRequestError, ConflictError, CustomError, ERRORS, ErrorProps, ErrorStatus, ForbiddenError, ICustomError, InternalServerError, JoiValidationError, NotAuthorizedError, NotFoundError, RateLimitError, SomeError, UnprocessableEntityError, ValidationError, setmessages as messages };

@@ -36,5 +36,3 @@ "use strict";

ValidationError: () => ValidationError,
messages: () => messages,
msg: () => msg,
setdefaultmessage: () => setdefaultmessage
messages: () => setmessages
});

@@ -61,3 +59,3 @@ module.exports = __toCommonJS(src_exports);

};
var setdefaultmessage = (t) => {
var setmessages = (t) => {
Object.assign(messages, t);

@@ -115,6 +113,2 @@ };

var ForbiddenError = class extends CustomError {
/**
*
* @default thou shalt not
*/
constructor(message = messages[403]) {

@@ -133,6 +127,2 @@ super(message);

var InternalServerError = class extends CustomError {
/**
*
* @default internal server error
*/
constructor(message = messages[500]) {

@@ -160,3 +150,3 @@ super(message);

message: error.message,
path: error.path[0]?.toString()
path: error.path.join(".")
}));

@@ -181,6 +171,2 @@ }

var NotFoundError = class extends CustomError {
/**
*
* @default not found
*/
constructor(message = messages[404]) {

@@ -198,6 +184,2 @@ super(message);

var RateLimitError = class extends CustomError {
/**
*
* @default too many requests. please try again later
*/
constructor(message = messages[429]) {

@@ -280,5 +262,3 @@ super(message);

ValidationError,
messages,
msg,
setdefaultmessage
messages
});

5

package.json
{
"name": "@kamalyb/errors",
"version": "2.0.1",
"version": "2.0.2",
"description": "errors",

@@ -50,3 +50,4 @@ "publishConfig": {

"joi": "^17.8.3"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

@@ -9,6 +9,2 @@ import { messages } from "../utils";

/**
*
* @default thou shalt not
*/
constructor(public message: string = messages[403]) {

@@ -15,0 +11,0 @@ super(message);

@@ -9,6 +9,2 @@ import { messages } from "../utils";

/**
*
* @default internal server error
*/
constructor(public message: string = messages[500]) {

@@ -15,0 +11,0 @@ super(message);

@@ -17,5 +17,5 @@ import type { ValidationErrorItem } from "joi";

message: error.message,
path: error.path[0]?.toString()
path: error.path.join(".")
}));
}
}

@@ -12,6 +12,2 @@ import type { CustomErrorParam, ErrorProps } from "../types";

/**
*
* @default you shall not pass
*/
constructor(message?: string);

@@ -18,0 +14,0 @@ constructor(props?: ErrorProps);

@@ -9,6 +9,2 @@ import { CustomError } from "./custom";

/**
*
* @default not found
*/
constructor(message: string = messages[404]) {

@@ -15,0 +11,0 @@ super(message);

@@ -9,6 +9,2 @@ import { messages } from "../utils";

/**
*
* @default too many requests. please try again later
*/
constructor(public message: string = messages[429]) {

@@ -15,0 +11,0 @@ super(message);

@@ -1,3 +0,3 @@

export * from "./utils";
export * from "./errors";
export * from "./types";
export { ERRORS, ICustomError, setmessages as messages } from "./utils";
export { ErrorProps, ErrorStatus } from "./types";

@@ -7,9 +7,4 @@ export interface ErrorProps {

export type CustomErrorParam =
| string
| string[]
| ErrorProps
| ErrorProps[]
| Array<string | ErrorProps>;
export type CustomErrorParam = string | ErrorProps | Array<string | ErrorProps>;
export type ErrorStatus = 400 | 401 | 403 | 404 | 409 | 422 | 429 | 500;

@@ -28,3 +28,3 @@ import type { ValidationErrorItem } from "joi";

export const setdefaultmessage = (t: Partial<typeof messages>) => {
export const setmessages = (t: Partial<typeof messages>) => {
Object.assign(messages, t);

@@ -31,0 +31,0 @@ };

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