Show your support!
TryCatch.js is a JavaScript library to help you handle your errors in a more clean & structured way.
How to use TryCatch.js:
import {tryCatch} from 'https://cdn.jsdelivr.net/gh/MarketingPipeline/TryCatch.js@v1.0.0/dist/trycatch.min.js';
// Example 1: try-catch-finally
tryCatch(
function() {
// some code that may throw an exception
},
function(e) {
// handle the exception
},
function() {
// code that is always executed, whether or not an exception is thrown
}
);
// Example 2: try-catch-else-finally
tryCatch(
function() {
// some code that may throw an exception
},
function(e) {
// handle the exception
},
function() {
// code that is always executed, whether or not an exception is thrown
},
function() {
// code that is executed if the try block returns undefined
}
);
// Example 3: try-catch
tryCatch(
function() {
// some code that may throw an exception
},
function(e) {
// handle the exception
}
);
// Example 4: try-finally
tryCatch(
function() {
// some code that may throw an exception
},
null,
function() {
// code that is always executed, whether or not an exception is thrown
}
);
Want to improve this? Create a pull request with detailed changes / improvements! If approved you will be added to the list of contributors of this awesome project!
See also the list of contributors who participate in this project.
This project is licensed under the MIT License - see the LICENSE file for details.