Add hooks for handling error