Added error code handling from error result. Will now supply correct err...

...or type.