Socket
Socket
Sign inDemoInstall

chromium-net-errors-urlbox

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chromium-net-errors-urlbox

Chromium network errors for Chromium-based JavaScript environments


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
43.4 kB
Created
Weekly downloads
 

Readme

Source

Chromium Network Errors

Build Status

Provides Chromium network errors found in net_error_list.h as custom errors for Node.js.

They correspond to the error codes that could be provided by Electron's did-fail-load event, for example.

Install

npm install chromium-net-errors --save

Example Electron app

var app = require('app');
var BrowserWindow = require('browser-window');
var networkErrors = require('chromium-net-errors');

app.on('ready', function () {

  var win = new BrowserWindow({ width: 800, height: 600 });

  win.webContents.on('did-fail-load', function (e, errorCode) {
    throw networkErrors.createByCode(errorCode);
  });

  win.loadUrl('http://blablanotexist.com');

});

Will pop-up the following error:

Uncaught Exception:
NameNotResolvedError: The host name could not be resolved.
    at Object.exports.createByCode (/tmp/ele/node_modules/chromium-net-errors/index.js:72:9)
    at EventEmitter.<anonymous> (/tmp/ele/app.js:10:25)
    at emitThree (events.js:97:13)
    at EventEmitter.emit (events.js:172:7)

Usage

var cne = require('chromium-net-errors');

Create new errors

var err = new cne.ConnectionTimedOutError();

console.log(err instanceof Error); // true
console.log(err instanceof cne.ChromiumNetError); // true
console.log(err instanceof cne.ConnectionTimedOutError); // true

Create errors by code

var err = cne.createByCode(-201);

console.log(err instanceof cne.CertDateInvalidError);
// true

console.log(err.isCertificateError());
// true

console.log(err.type); 
// certificate

console.log(err.message);
// The server responded with a certificate that is signed by an authority
// we don't trust.  The could mean:
//
// 1. An attacker has substituted the real certificate for a cert that
//    contains his public key and is signed by his cousin.
//
// 2. The server operator has a legitimate certificate from a CA we don't
//    know about, but should trust.
//
// 3. The server is presenting a self-signed certificate, providing no
//    defense against active attackers (but foiling passive attackers).

License

MIT

Keywords

FAQs

Last updated on 06 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc