Skip to content

Error handler that invokes functions and catches possible errors with little to no damage

Notifications You must be signed in to change notification settings

SethClydesdale/window.run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

window.run

This is a small helper function which will try your function and catch any errors that may occur. The purpose of it is simple ; Run the function and catch erroneous code to prevent any damage during runtime.

Examples

1. Automatic error catching

congole is undefined so this exeception will automatically be caught, thus allowing JavaScript to continue executing as if nothing went wrong.

run(function() {
  congole.log('Hi !');
});

console.log('Phew, that was close..');

2. Handling errors

To handle errors or view the error object, you can attach handle to the end of run. The function passed to handle will only be executed if an error occurs.

run(function() {
  congole.log('Hi !');
})
.handle(function(err) {
  console.log(err); // log error object
  console.log('Sorry, I meant console.');
});

About

Error handler that invokes functions and catches possible errors with little to no damage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published