mirror of
https://github.com/Grace-Solutions/PSMinIO.git
synced 2026-08-06 03:27:40 +00:00
Reduce error handling verbosity and start enhanced upload cmdlet
- Simplified error handling to show only essential information: * Operation, Message, ExceptionType, InnerExceptionType, InnerExceptionMessage * Removed system info, stack traces, and operation details for cleaner output - Started enhancing New-MinIOObject cmdlet with parameter sets: * SingleFile: Original single file upload functionality * Files: FileInfo[] support for multiple file uploads * Directory: DirectoryInfo support with recursive options - Added new parameters for enhanced functionality: * BucketDirectory for organizing uploads into nested structures * Recursive, MaxDepth, Flatten for directory uploads * InclusionFilter, ExclusionFilter for file filtering * Force parameter for overwriting existing objects Next: Complete the parameter set implementation and add multi-layer progress tracking.
This commit is contained in:
@@ -97,40 +97,19 @@ namespace PSMinIO.Utils
|
||||
private static OrderedDictionary CreateDetailedErrorInfo(Exception exception, string operationName, string? operationDetails)
|
||||
{
|
||||
var errorDetails = new OrderedDictionary();
|
||||
|
||||
|
||||
// Basic error information
|
||||
errorDetails.Add("Operation", operationName);
|
||||
errorDetails.Add("Message", exception.Message);
|
||||
errorDetails.Add("ExceptionType", exception.GetType().FullName);
|
||||
|
||||
// Operation details if provided
|
||||
if (!string.IsNullOrEmpty(operationDetails))
|
||||
{
|
||||
errorDetails.Add("OperationDetails", operationDetails);
|
||||
}
|
||||
|
||||
|
||||
// Inner exception information
|
||||
if (exception.InnerException != null)
|
||||
{
|
||||
errorDetails.Add("InnerExceptionType", exception.InnerException.GetType().FullName);
|
||||
errorDetails.Add("InnerExceptionMessage", exception.InnerException.Message);
|
||||
}
|
||||
|
||||
// Stack trace information
|
||||
if (!string.IsNullOrEmpty(exception.StackTrace))
|
||||
{
|
||||
var stackLines = exception.StackTrace.Split('\n');
|
||||
if (stackLines.Length > 0)
|
||||
{
|
||||
errorDetails.Add("StackTraceTop", stackLines[0].Trim());
|
||||
}
|
||||
}
|
||||
|
||||
// System information
|
||||
errorDetails.Add("Timestamp", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss UTC"));
|
||||
errorDetails.Add("MachineName", Environment.MachineName);
|
||||
errorDetails.Add("ProcessId", Process.GetCurrentProcess().Id);
|
||||
|
||||
|
||||
return errorDetails;
|
||||
}
|
||||
|
||||
@@ -144,10 +123,7 @@ namespace PSMinIO.Utils
|
||||
{
|
||||
var timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// Log header
|
||||
cmdlet.WriteWarning($"{timestamp} - ERROR: PSMinIO Operation Failed");
|
||||
|
||||
// Log each error detail
|
||||
// Log each error detail (reduced set)
|
||||
foreach (DictionaryEntry detail in errorDetails)
|
||||
{
|
||||
var key = detail.Key?.ToString() ?? "Unknown";
|
||||
@@ -159,7 +135,7 @@ namespace PSMinIO.Utils
|
||||
value = value.Substring(0, 197) + "...";
|
||||
}
|
||||
|
||||
cmdlet.WriteWarning($"{timestamp} - ERROR: {key}: {value}");
|
||||
cmdlet.WriteWarning($"{timestamp} - {key}: {value}");
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
|
||||
Reference in New Issue
Block a user