Skip to content

Commit

Permalink
Improvement if file was not found (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
strivitech authored Aug 10, 2022
1 parent 16a6281 commit 923bcba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Google;
using Google.Api.Gax;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Storage.v1.Data;
Expand Down Expand Up @@ -60,6 +61,10 @@ await StorageClient.DownloadObjectAsync(
fileStream.Position = 0;
return new TFile { ContentStream = fileStream, ContentType = fileObject.ContentType };
}
catch (GoogleApiException)
{
return null;
}
catch (Exception ex)
{
throw new FileStorageException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface IFilesStorage<TFile, TIdentifier>
/// <param name="fileId">File id.</param>
/// <param name="cancellationToken">CancellationToken.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.
/// The task result contains a file of type <see cref="TFile"/>.
/// The task result contains a file of type <see cref="TFile"/> or null if it was not found.
/// </returns>
Task<TFile> GetByIdAsync(TIdentifier fileId, CancellationToken cancellationToken = default);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task<Result<ImageDto>> GetByIdAsync(string imageId)

if (externalImageModel == null)
{
logger.LogDebug("Image with id='{ImageId}' wasn't found", imageId);
return Result<ImageDto>.Failed(ImagesOperationErrorCode.ImageNotFoundError.GetOperationError());
}

Expand Down

0 comments on commit 923bcba

Please sign in to comment.