Add error check for add_handler directive