Added documentation for error handling