| | 1 | | using System.Collections; |
| | 2 | | using System.Diagnostics; |
| | 3 | | using System.Diagnostics.CodeAnalysis; |
| | 4 | |
|
| | 5 | | namespace mkmrk.Channels; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Error occurred when writing to Channel |
| | 9 | | /// </summary> |
| | 10 | | [ SuppressMessage( "Design", "CA1032:Implement standard exception constructors" ) ] |
| | 11 | | public class ChannelWriteException : System.Exception { |
| | 12 | | /// <inheritdoc cref="ChannelWriteException" /> |
| 0 | 13 | | internal ChannelWriteException( string? message, System.Exception? innerException = null ) : base( message, innerExc |
| | 14 | |
|
| | 15 | | /// <inheritdoc cref="ChannelWriteException" /> |
| | 16 | | [ DoesNotReturn ] |
| | 17 | | [ StackTraceHidden ] |
| 0 | 18 | | public static void Throw( string? message = null, IDictionary? data = null, System.Exception? innerException = null |
| 0 | 19 | | var exception = new ChannelWriteException( message, innerException ); |
| 0 | 20 | | if ( data is { } ) { |
| 0 | 21 | | foreach ( var key in data.Keys ) { |
| 0 | 22 | | exception.Data.Add( key, data[ key ] ); |
| 0 | 23 | | } |
| 0 | 24 | | } |
| 0 | 25 | | throw exception; |
| | 26 | | } |
| | 27 | |
|
| | 28 | | /// <inheritdoc cref="ChannelWriteException" /> |
| | 29 | | [ DoesNotReturn ] |
| | 30 | | [ StackTraceHidden ] |
| 0 | 31 | | public static void Throw<TChannelWriter>( string operation, IDictionary? data = null, System.Exception? innerExcepti |
| 0 | 32 | | var exception = new ChannelWriteException( $"An error occurred when writing to {typeof(TChannelWriter).GenericTy |
| 0 | 33 | | if ( data is { } ) { |
| 0 | 34 | | foreach ( var key in data.Keys ) { |
| 0 | 35 | | exception.Data.Add( key, data[ key ] ); |
| 0 | 36 | | } |
| 0 | 37 | | } |
| 0 | 38 | | throw exception; |
| | 39 | | } |
| | 40 | | } |