-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTemporaryStreamErrorHandlerProvider.cs
More file actions
28 lines (23 loc) · 1.09 KB
/
TemporaryStreamErrorHandlerProvider.cs
File metadata and controls
28 lines (23 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
namespace Light.TemporaryStreams;
/// <summary>
/// Provides an optional delegate to handle errors when deleting temporary files.
/// </summary>
public sealed class TemporaryStreamErrorHandlerProvider
{
private readonly Action<TemporaryStream, Exception>? _errorHandler;
/// <summary>
/// Initializes a new instance of <see cref="TemporaryStreamErrorHandlerProvider" />.
/// </summary>
/// <param name="errorHandler">
/// An optional delegate that is executed when an exception occurs while deleting a temporary file. The first
/// parameter is the <see cref="TemporaryStream" /> that triggered the deletion attempt, and the second parameter
/// is the exception that was thrown.
/// </param>
public TemporaryStreamErrorHandlerProvider(Action<TemporaryStream, Exception>? errorHandler) =>
_errorHandler = errorHandler;
/// <summary>
/// Gets the delegate that is executed when an exception occurs while deleting a temporary file.
/// </summary>
public Action<TemporaryStream, Exception>? GetErrorHandlerDelegate() => _errorHandler;
}