diff --git a/src/Commands/UserProfiles/GetUPABulkImportStatus.cs b/src/Commands/UserProfiles/GetUPABulkImportStatus.cs index 964b4b570d..5dafb9b6cd 100644 --- a/src/Commands/UserProfiles/GetUPABulkImportStatus.cs +++ b/src/Commands/UserProfiles/GetUPABulkImportStatus.cs @@ -60,9 +60,22 @@ private void GetErrorInfo(ImportProfilePropertiesJobInfo job) string message = string.Empty; foreach (var logFile in files) message += "\r\n" + webCtx.Web.GetFileAsString(logFile.ServerRelativeUrl); - job.ErrorMessage = message; + TrySetJobErrorMessage(job, message); } } } + + private void TrySetJobErrorMessage(ImportProfilePropertiesJobInfo job, string message) + { + try + { + job.ErrorMessage = message; + } + catch (ClientRequestException) + { + // Setting the ErrorMessage property to ImportProfilePropertiesJobInfo returned by GetImportProfilePropertyJobs() throws an exception sometimes as the Path is property is null. + // In this case the generic error message with the file location of the log in SPO will be returned. + } + } } } \ No newline at end of file