Added support for error log

Now its possible to log the queries that have an error.