SHARE
TWEET

Untitled

a guest May 23rd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. const ERROR_RATE = 0.25
  4.  
  5. function should_fail () {
  6.   return Math.random() < ERROR_RATE
  7. }
  8.  
  9. function main(params) {
  10.   if (!params.a || !params.b) throw new Error('Missing input parameters (a or b).')
  11.   if (should_fail()) throw new Error('failed!')
  12.  
  13.   const sum = params.a + params.b
  14.   return { sum }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top