Custom error handling

Allow users to define their own errors for uploads, and provide a default error handling.