Add error handling for post hook