You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

unify-errors

Package Overview
Dependencies
Maintainers
1
Versions
378
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unify-errors - npm Package Compare versions

Comparing version

to
1.0.1

2

dist/index.d.ts
/**
* Context is used to pass informal data to the exception,
* We used a string any record to keep the flexibility.
* We used a string record to keep the flexibility.
*/

@@ -5,0 +5,0 @@ export declare type CustomErrorContext = Record<string, unknown>;

{
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",

@@ -60,12 +60,12 @@ "main": "dist/index.js",

"devDependencies": {
"@size-limit/preset-small-lib": "^7.0.8",
"husky": "^7.0.4",
"size-limit": "^7.0.8",
"tsdx": "^0.14.1",
"tslib": "^2.3.1",
"typescript": "^4.5.5",
"@size-limit/preset-small-lib": "7.0.8",
"husky": "7.0.4",
"size-limit": "7.0.8",
"tsdx": "0.14.1",
"tslib": "2.3.1",
"typescript": "4.6.3",
"np": "7.6.0",
"prettier": "2.6.0",
"@typescript-eslint/eslint-plugin": "5.15.0",
"@typescript-eslint/parser": "5.15.0",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.18.0",
"eslint": "8.11.0",

@@ -72,0 +72,0 @@ "eslint-config-prettier": "8.5.0",

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

[![Test Coverage](https://api.codeclimate.com/v1/badges/e79adf68b976c68f41a6/test_coverage)](https://codeclimate.com/github/flexper/unify-errors/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/e79adf68b976c68f41a6/maintainability)](https://codeclimate.com/github/flexper/unify-errorss/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/6be8e53efc66aabc6a5e/test_coverage)](https://codeclimate.com/github/flexper/unify-errors/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/6be8e53efc66aabc6a5e/maintainability)](https://codeclimate.com/github/flexper/unify-errorss/maintainability) ![npm](https://img.shields.io/npm/v/unify-errors) ![npm](https://img.shields.io/npm/dm/unify-errors) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/unify-errors) ![NPM](https://img.shields.io/npm/l/unify-errors)
# Unify errors

@@ -18,2 +19,52 @@

## API
### BadRequest(context?)
Return: CustomError with Bad Request message.
### Unauthorized(context?)
Return: CustomError with Unauthorized message.
### Forbidden(context?)
Return: CustomError with Forbidden message.
### NotFound(context?)
Return: CustomError with Not Found message.
### RequestTimeOut(context?)
Return: CustomError with Request TimeOut message.
### InternalServerError(context?)
Return: CustomError with Internal Server Error message.
### NotImplemented(context?)
Return: CustomError with Not Implemented message.
### CustomError(message, context?)
The CustomError class extends the basic typescript Error class. It is used to create all custom errors.
***Params***
| Field Name | Type | Default | Description |
| --- | --- | --- | --- |
| message | string | mandatory | Mandatory error message property |
| context | CustomErrorContext | {} | Optional record of string |
***How to use***
To create a new error type, export a new const function returning your desired custom error.
````typescript
export const BadRequest = (context?: CustomErrorContext) =>
new CustomError('Bad Request', context);
````
## Tests

@@ -20,0 +71,0 @@

/**
* Context is used to pass informal data to the exception,
* We used a string any record to keep the flexibility.
* We used a string record to keep the flexibility.
*/

@@ -5,0 +5,0 @@ export type CustomErrorContext = Record<string, unknown>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet