A throw within a Promise/Promise chain will automatically cause that Promise/Promise Chain to be rejected.
const myFunc = input => {
return new Promise((resolve, reject) => {
if (badInput) {
throw new Error('failed')
}
return resolve(sns.createTopic(input).promise())
})
}
return myFunc('some input')
.then(result => {
// handle result
})
.catch(err => { console.log(err) }) // will log 'failed'
However, your myCustomFunction isn't wrapped in a Promise, it is using throw before the Promise is returned by sns.createTopic().promise(). To create and return a Promise already in a rejected state you would use Promise.reject(new Error('failed')) instead of throw.