Add support for handling errors from agent registration