public static PSResourceManagerError ToPSResourceManagerError(this ResourceManagementError error)
        {
            PSResourceManagerError rmError = new PSResourceManagerError
            {
                Code    = error.Code,
                Message = error.Message,
                Target  = string.IsNullOrEmpty(error.Target) ? null : error.Target
            };

            if (!string.IsNullOrEmpty(error.Details))
            {
                var token = JToken.Parse(error.Details);
                if (token is JArray)
                {
                    var errors = error.Details.FromJson <ExtendedErrorInfo[]>();
                    List <PSResourceManagerError> innerRMErrors = new List <PSResourceManagerError>();
                    foreach (var innerError in errors)
                    {
                        innerRMErrors.Add(innerError.ToPSResourceManagerError());
                    }
                    rmError.Details = innerRMErrors;
                }
                else if (token is JObject)
                {
                    var innerError = error.Details.FromJson <ResourceManagementError>();
                    rmError.Details = new List <PSResourceManagerError> {
                        innerError.ToPSResourceManagerError()
                    };
                }
            }
            return(rmError);
        }
 public static PSResourceManagerError ToPSResourceManagerError(this ResourceManagementError error)
 {
     return(new PSResourceManagerError
     {
         Code = error.Code,
         Message = error.Message
     });
 }