replaced simple string errors with full Errors

Hi,

In order to keep the stacktrace in case of errors, I replaced simple string errors with Error objects, in order to make debugging easier.