Keep error code

I like that you pass the errors on to the custom error handler, but I miss the error codes =P Not sure if this is the right way to keep them or not though. Also, it looks like there are some extra commits in here, but I think they're all from ebidel/master. You might want to fetch his changes first though to be sure.