Playing with JS promises and capturing errors