Improved Error Handling

Added documentation and implementation for improved error handling. It
is now also possible to call the next function with an error object
instead of throwing it.