Add a bootstrap modal into your code. And call it from your catch block.
try { // todo } catch (err) { $('#errorModal').modal('toggle') }