New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

error-provider

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-provider - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

29

lib/error-provider.js

@@ -65,3 +65,3 @@ "use strict";

var codes = {
errors._codes = {
"-1": "UNKNOWN",

@@ -141,10 +141,6 @@ "0": "OK",

errors[code] = e;
codes[errno] = code;
this[code] = e;
this._codes[errno] = code;
};
var replace = function (s, k, v){
return s.replace (new RegExp ("\\{" + k + "\\}", "g"), v);
};
errors.get = function (id, vars){

@@ -155,5 +151,5 @@ var error;

if (type === "number"){
error = errors[codes[id]];
error = this[this._codes[id]];
}else if (type === "string"){
error = errors[id];
error = this[id];
}else{

@@ -189,8 +185,15 @@ error = id;

var next = 100;
errors.local = function (){
return {
create: errors.create,
get: errors.get,
next: errors.next,
_next: 0,
_codes: {}
};
};
errors._next = 100;
errors.next = function (){
var n = next;
next++;
return n;
return this._next++;
};
{
"name": "error-provider",
"version": "0.0.2",
"version": "0.0.3",
"description": "Manages errors for third-party modules",

@@ -5,0 +5,0 @@ "keywords": ["error", "errno", "provider", "libuv"],

@@ -8,3 +8,3 @@ error-provider

Version: 0.0.2
Version: 0.0.3

@@ -93,2 +93,10 @@ When you're writing a third-party module you'll probably deal with errors. If you want to send custom errors to your users you should send a code and then in your documentation explain these codes.

There's a special method called `local()` that returns a local error provider. If you need a local storage with custom errors that you don't need to make public, `local()` can help you. If another third-party module uses the `error-provider` module you won't see its errors, the local error provider is local to your module. The first available errno is 0 and the set of default codes is empty, that is, you can't return a built-in error like `EEXIST`. You can create all the storages you want.
```javascript
var ep = require ("error-provider").local ();
ep.create (ep.next (), ...);
ep.get (...);
```
- [ep.create(errno, code, description[, properties])](#create)

@@ -95,0 +103,0 @@ - [ep.get(id[, vars])](#get)

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