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

whoops

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whoops - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

14

CHANGELOG.md

@@ -0,1 +1,15 @@

<a name="4.0.2"></a>
## 4.0.2 (2019-03-08)
* fix(package): update clean-stack to version 2.0.0 ([24952ae](https://github.com/kikobeats/whoops/commit/24952ae))
* fix(package): update mimic-fn to version 1.2.0 ([719fc26](https://github.com/kikobeats/whoops/commit/719fc26))
* fix(package): update mimic-fn to version 2.0.0 ([d5c78a1](https://github.com/kikobeats/whoops/commit/d5c78a1))
* Refactor ([64f751b](https://github.com/kikobeats/whoops/commit/64f751b))
* Update compositor.json ([e26b0fd](https://github.com/kikobeats/whoops/commit/e26b0fd))
* Update compositor.json ([da98ea7](https://github.com/kikobeats/whoops/commit/da98ea7))
* Update README.md ([0228c84](https://github.com/kikobeats/whoops/commit/0228c84))
* docs(readme): add Greenkeeper badge ([4e1a125](https://github.com/kikobeats/whoops/commit/4e1a125))
<a name="4.0.1"></a>

@@ -2,0 +16,0 @@ ## 4.0.1 (2017-08-08)

9

lib/create-error.js

@@ -9,5 +9,10 @@ 'use strict'

function createError (className) {
if (typeof className !== 'string') throw new TypeError('Expected className to be a string')
if (REGEX_CLASS_NAME.test(className)) throw new Error('className contains invalid characters')
if (typeof className !== 'string') {
throw new TypeError('Expected className to be a string')
}
if (REGEX_CLASS_NAME.test(className)) {
throw new Error('className contains invalid characters')
}
function ErrorClass () {

@@ -14,0 +19,0 @@ Object.defineProperty(this, 'name', {

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

"homepage": "https://github.com/Kikobeats/whoops",
"version": "4.0.1",
"version": "4.0.2",
"main": "lib/index.js",

@@ -28,4 +28,4 @@ "author": {

"dependencies": {
"clean-stack": "~1.3.0",
"mimic-fn": "~1.1.0"
"clean-stack": "~2.0.0",
"mimic-fn": "~2.0.0"
},

@@ -32,0 +32,0 @@ "devDependencies": {

@@ -17,3 +17,3 @@ # whoops

- Using the standard `Error` interface in browser and NodeJS.
- Attach extra information, depending of your case of use.
- Attach extra information, being flexible with whatever user case.

@@ -52,7 +52,6 @@ This library is a compromise to provide a clean API for use `Error` native class.

const myError = whoops()
throw myError()
```
If you provided a `className` you get a qualified constructor function that extends from `Error`:
Create domain specific errors providing a `className` as first argument:

@@ -62,12 +61,19 @@ ```js

const userError = whoops('userError')
throw userError()
```
Providing `props` as second parameter you can attach extra information that always will be associated with the `error`:
The qualified error will be extends from `Error`:
```js
const whoops = require('whoops')
const userError = whoops('userError')
const error = userError()
console.log(error instanceof Error); // => true
```
Attach extra information passing a `props` as second argument:
```js
const whoops = require('whoops')
const userError = whoops('userError', {code: 'ENOVALID'})
const err = userError()

@@ -77,3 +83,3 @@ console.log(`My error code is ${err.code}`) // => My error code is ENOVALID

Also, you can associate dynamic `props` at the moment of the `error`:
You can associate dynamic `props` as well:

@@ -80,0 +86,0 @@ ```js

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