DEV Community

Discussion on: Practical Functional Programming in JavaScript - Error Handling

Collapse
 
detzam profile image
webstuff

Question about the try catch.
Should you use it only when you develop the code and after all testing is dobe should you remove it? Or you let it in production?

Collapse
 
richytong profile image
Richard Tong

tryCatch (along with any of the rubico functions) is meant for production use. Here is a fresh benchmark run for tryCatch

noop: 1e+5: 3.224ms
tryCatch_caught_vanilla: 1e+5: 776.34ms
tryCatch_caught_rubicoHappyPath: 1e+5: 772.816ms
tryCatch_caught_rubicoFullInit: 1e+5: 789.817ms
identity: 1e+6: 8.925ms
tryCatch_identity_vanilla: 1e+6: 9.44ms
tryCatch_identity_rubicoHappyPath: 1e+6: 12.431ms
tryCatch_identity_rubicoFullInit: 1e+6: 70.184ms

Here's the benchmark file for tryCatch if you'd like to run the benchmarks. github.com/a-synchronous/rubico/bl...