ensure exceptions are correctly handle in AJAX handlers (i.e. return JSON responses)