Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPLOAD-599: printing exception stack trace #162

Merged
merged 20 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions BulkFileUploadFunctionApp/BulkFileUploadFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
throw new TusInfoFileException(e.Message);
}

_logger.LogInformation($"Info file metadata keys: {string.Join(", ", tusInfoFile.MetaData?.Keys.ToList())}");

Check warning on line 258 in BulkFileUploadFunctionApp/BulkFileUploadFunction.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'values' in 'string string.Join(string? separator, IEnumerable<string?> values)'.

Check warning on line 258 in BulkFileUploadFunctionApp/BulkFileUploadFunction.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'values' in 'string string.Join(string? separator, IEnumerable<string?> values)'.

return tusInfoFile;
}
Expand Down Expand Up @@ -327,24 +327,21 @@
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 @@
}
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());
}
}
}
}