Skip to content

Commit

Permalink
Handle exceptions when setting the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpoz committed Oct 13, 2023
1 parent ebbf4bc commit 991844d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Commands/UserProfiles/GetUPABulkImportStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
}
}

0 comments on commit 991844d

Please sign in to comment.