changes result.error to result.Error
also wraps it in an Error object