Error handling and documentation