Improve error handling and reporting on hooks