Skip to content

Commit

Permalink
Issue #138 - Implement WriteError
Browse files Browse the repository at this point in the history
* WriteError implemented into BaseDSClientBackupSetDataBrowser class in place of throw exception
McGlovin1337 committed Nov 2, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f430523 commit 8378839
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions PSAsigraDSClient/BaseDSClientBackupSetDataBrowser.cs
Original file line number Diff line number Diff line change
@@ -28,7 +28,14 @@ protected override void DSClientProcessRecord()
if (validationSession != null)
ProcessBackupSetData(validationSession.GetValidationView());
else
throw new Exception("Specified Validation Session not found");
{
ErrorRecord errorRecord = new ErrorRecord(
new ArgumentException("Specified Validation Session not found"),
"PSArgumentException",
ErrorCategory.ObjectNotFound,
null);
WriteError(errorRecord);
}
}
else if (MyInvocation.BoundParameters.ContainsKey(nameof(DeleteId)))
{
@@ -38,7 +45,14 @@ protected override void DSClientProcessRecord()
if (deleteSession != null)
ProcessBackupSetData(deleteSession.GetDeleteView());
else
throw new Exception("Specified Delete Session not found");
{
ErrorRecord errorRecord = new ErrorRecord(
new ArgumentException("Specified Delete Session not found"),
"PSArgumentException",
ErrorCategory.ObjectNotFound,
null);
WriteError(errorRecord);
}
}
else if (MyInvocation.BoundParameters.ContainsKey(nameof(RestoreId)))
{
@@ -47,28 +61,44 @@ protected override void DSClientProcessRecord()
if (restoreSession != null)
ProcessBackupSetData(restoreSession.GetRestoreView());
else
throw new Exception("Specified Restore Session not found");
{
ErrorRecord errorRecord = new ErrorRecord(
new ArgumentException("Specified Restore Session not found"),
"PSArgumentException",
ErrorCategory.ObjectNotFound,
null);
WriteError(errorRecord);
}
}
else
{
BackupSet backupSet = DSClientSession.backup_set(BackupSetId);

if (backupSet.check_lock_status(EActivityType.EActivityType__Restore) == EBackupSetLockStatus.EBackupSetLockStatus__Locked)
throw new Exception("Backup Set is Currently Locked");

int deletedDate = 0;
{
ErrorRecord errorRecord = new ErrorRecord(
new Exception("Backup Set is Currently Locked"),
"Exception",
ErrorCategory.ResourceBusy,
backupSet);
WriteError(errorRecord);
}
else
{
int deletedDate = 0;

if (MyInvocation.BoundParameters.ContainsKey("DeletedDate"))
deletedDate = DateTimeToUnixEpoch(DeletedDate);
if (MyInvocation.BoundParameters.ContainsKey("DeletedDate"))
deletedDate = DateTimeToUnixEpoch(DeletedDate);

WriteVerbose("Performing Action: Prepare Backup Set Data view");
WriteVerbose("Notice: From: " + DateFrom + " To: " + DateTo);
BackupSetRestoreView backupSetRestoreView = backupSet.prepare_restore(DateTimeToUnixEpoch(DateFrom), DateTimeToUnixEpoch(DateTo), deletedDate);
WriteVerbose("Performing Action: Prepare Backup Set Data view");
WriteVerbose("Notice: From: " + DateFrom + " To: " + DateTo);
BackupSetRestoreView backupSetRestoreView = backupSet.prepare_restore(DateTimeToUnixEpoch(DateFrom), DateTimeToUnixEpoch(DateTo), deletedDate);

ProcessBackupSetData(backupSetRestoreView);
ProcessBackupSetData(backupSetRestoreView);

backupSetRestoreView.Dispose();
backupSet.Dispose();
backupSetRestoreView.Dispose();
backupSet.Dispose();
}
}
}
}

0 comments on commit 8378839

Please sign in to comment.