Skip to content

Commit

Permalink
Fix name typo and update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
webprofusion-chrisc committed Nov 5, 2024
1 parent 178b325 commit 478e7c3
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,32 @@ internal async Task UpdateStoredCredential(string[] args)
var cred = new StoredCredential
{
StorageKey = storageKey,
DateCreated = DateTime.Now,
DateCreated = DateTime.UtcNow,
ProviderType = credentialType,
Secret = secretValue,
Title = title
};

var result = await _certifyClient.UpdateCredentials(cred);

if (result != null)
try
{
var resultObject = new { Status = "OK", Message = "Credential updated", StorageKey = result?.StorageKey };
var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented);
Console.WriteLine(output);
var result = await _certifyClient.UpdateCredentials(cred);
if (result != null)
{

var resultObject = new { Status = "OK", Message = "Credential updated", StorageKey = result?.StorageKey };
var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented);
Console.WriteLine(output);
}
else
{
var resultObject = new { Status = "Error", Message = "Credential update failed" };
var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented);
Console.WriteLine(output);
}
}
else
catch (Exception ex)
{
var resultObject = new { Status = "Error", Message = "Credential update failed" };
var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented);
Console.WriteLine(output);
Console.WriteLine($"Error updating credentials: {ex.Message}");
}
}

Expand All @@ -55,5 +62,10 @@ internal async Task ListStoredCredentials(string[] args)

Console.WriteLine(output);
}
private void WriteOutput(object resultObject)
{
var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented);
Console.WriteLine(output);
}
}
}

0 comments on commit 478e7c3

Please sign in to comment.