doc: document error handling functions and conventions