/FailFast

JavaScript library to help you detect errors in your code faster

Primary LanguageJavaScript

FailFast helps you detect errors in your code faster

You can use FailFast to safeguard functions from bad input, and giving the caller an early warning that bad input is being passed.


// define a function, using FailFast to protect itself from bad input
function myFunction( myParam ){
        FailFast.assertNumber( 'myParam must be a number, you passed: ' + myParam, myParam );
        // your real code here
}

// call the function with bad input
myFunction( 'lorem ipsum' );

// throws Error with message property of
// "myParam must be a number, you passed: lorem ipsum"
// the execution will be halted, and the developer will immediately see
// what he's done wrong

More reading about failing fast