throw an error if a functions is taking too long in javascript code example Example: how to raise exception in js throw new Error('Exception message');