Skip to content

Instantly share code, notes, and snippets.

@abrahamspaa
Created June 30, 2020 20:33
Show Gist options
  • Save abrahamspaa/8bcf24caf9d2e2ba326856a4e468e5a8 to your computer and use it in GitHub Desktop.
Save abrahamspaa/8bcf24caf9d2e2ba326856a4e468e5a8 to your computer and use it in GitHub Desktop.
const EventEmitter = require('events').EventEmitter;
const ErrorEvent = new EventEmitter;
ErrorEvent.on('error', message =>
console.error(`Error Occured due to: ${message}`));
(message => {
ErrorEvent.emit('error', message);
})('Code is not defined');
// Output will be
// Error Occured due to: Code is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment