Skip to content

Commit

Permalink
UPLOAD-599: printing exception stack trace (#162)
Browse files Browse the repository at this point in the history
* printing exception stack trace
  • Loading branch information
rohitpanwar authored Oct 2, 2023
1 parent e1fbddd commit 6165e9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
16 changes: 7 additions & 9 deletions BulkFileUploadFunctionApp/BulkFileUploadFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,24 +327,21 @@ private async Task CopyBlobFromDexToEdavAsync(string sourceContainerName, string
string destinationContainerName = string.IsNullOrEmpty(_edavUploadRootContainerName) ? sourceContainerName : _edavUploadRootContainerName;
string destinationBlobFilename = string.IsNullOrEmpty(_edavUploadRootContainerName) ? sourceBlobFilename : $"{sourceContainerName}/{sourceBlobFilename}";


var edavContainerClient = edavBlobServiceClient.GetBlobContainerClient(destinationContainerName);

await edavContainerClient.CreateIfNotExistsAsync();


BlobClient edavDestBlobClient = edavContainerClient.GetBlobClient(destinationBlobFilename);

using var dexBlobStream = await dexBlobClient.OpenReadAsync();
{
await edavDestBlobClient.UploadAsync(dexBlobStream, null, destinationMetadata);
dexBlobStream.Close();
}

}
catch (Exception ex)
{
_logger.LogError("Failed to copy", ex.Message);
}
}
catch (Exception ex) {
_logger.LogError("Failed to copy from Dex to Edav");
ExceptionUtils.LogErrorDetails(ex, _logger);
}
}

Expand Down Expand Up @@ -383,7 +380,8 @@ private async Task CopyBlobFromTusToDexAsync(string connectionString, string sou
}
catch (RequestFailedException ex)
{
_logger.LogError(ex.Message);
_logger.LogError("Failed to copy from TUS to Dex");
ExceptionUtils.LogErrorDetails(ex, _logger);
}
}

Expand Down
19 changes: 19 additions & 0 deletions BulkFileUploadFunctionApp/Utils/ExceptionUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Extensions.Logging;

namespace BulkFileUploadFunctionApp.Utils
{
internal class ExceptionUtils
{
public static void LogErrorDetails(Exception ex, ILogger _logger)
{
if(ex is AggregateException) {
AggregateException ae = (AggregateException)ex;
foreach (Exception innerException in ae.Flatten().InnerExceptions) {
_logger.LogError(innerException.ToString());
}
} else {
_logger.LogError(ex.GetBaseException().ToString());
}
}
}
}

0 comments on commit 6165e9d

Please sign in to comment.