Try surrounding your event callback code with a $timeout. I suspect your code is running outside of Angular-land so wrapping in a $timeout will have your code block execute in the next Angular digest loop and have it handled properly by Angular's $exceptionHandler
.
app.directive('saveAndShowDialog', ['$timeout', function($timeout) {
function link(scope, element, attrs) {
element.on('click', function(e) {
$timeout(function(){
var x = y; // forces exception
scope.save();
});
});
}
return { restrict: 'A', link: link };
}]);