Added documentation and custom error messages