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

@dazn/chaos-squirrel-attack-throw-error

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dazn/chaos-squirrel-attack-throw-error

Chaos Squirrel attack to throw an exception

  • 0.10.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
7
Weekly downloads
 
Created
Source

@dazn/chaos-squirrel-attack-throw-error

Causes an error to be thrown - either directly or via setImmediate causing uncaught exception.

Attack options

ParameterTypeDefaultDescription
errorClassErrConstructorErrorInstance of that class will be thrown. The class should extend Error.
errorMessagestringchaos-squirrel: attack-throw-errorError message
uncaughtExceptionbooleanfalseFlag that decides if uncaught exception is thrown

Examples

Immediately thrown error

import ThrowErrorAttack from '@dazn/chaos-squirrel-attack-throw-error';;

class CustomError extends Error {
  constructor(message?: string) {
    super(message);
  }
}
const errorMessage = 'Chaos!';
const attack = new ThrowErrorAttack({
    errorClass: CustomError,
    errorMessage
});

try {
    attack.start();
} catch (err) {
    err instanceof CustomError // true
    console.log(err.message) // Chaos!
}

Uncaught exception

import ThrowErrorAttack from '@dazn/chaos-squirrel-attack-throw-error';

const attack = new ThrowErrorAttack({ uncaughtException: true });

process.on('uncaughtException', (err) => {
    err instanceof Error // true
    console.log(err.message) // chaos-squirrel: attack-throw-error
})

attack.start();
console.log('Still alive');
// Uncaught exception is thrown via setImmediate so "check" phase

Stopping uncaught exception

import ThrowErrorAttack from '@dazn/chaos-squirrel-attack-throw-error';

const attack = new ThrowErrorAttack({ uncaughtException: true });

attack.start();
attack.stop();
// nothing bad is gonna happen

Uncaught exception

To cause an uncaught exception an error is being thrown from setImmediate callback. See docs.

FAQs

Package last updated on 12 Mar 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc