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