Trying to catch the error but ES6 is not working