|
| 1 | +namespace ModularPipelines.Exceptions; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Exception thrown when a plugin fails to initialize during pipeline setup. |
| 5 | +/// </summary> |
| 6 | +/// <remarks> |
| 7 | +/// <para> |
| 8 | +/// This exception is thrown when a plugin's <c>ConfigureServices</c> or <c>ConfigurePipeline</c> |
| 9 | +/// method throws an exception. Plugin initialization failures are fatal and stop the pipeline |
| 10 | +/// from executing. |
| 11 | +/// </para> |
| 12 | +/// <para><b>Example:</b></para> |
| 13 | +/// <code> |
| 14 | +/// try |
| 15 | +/// { |
| 16 | +/// await pipelineBuilder.ExecutePipelineAsync(); |
| 17 | +/// } |
| 18 | +/// catch (PluginInitializationException ex) |
| 19 | +/// { |
| 20 | +/// Console.WriteLine($"Plugin '{ex.PluginName}' failed: {ex.Message}"); |
| 21 | +/// } |
| 22 | +/// </code> |
| 23 | +/// </remarks> |
| 24 | +public class PluginInitializationException : PipelineException |
| 25 | +{ |
| 26 | + /// <summary> |
| 27 | + /// Gets the name of the plugin that failed to initialize. |
| 28 | + /// </summary> |
| 29 | + public string PluginName { get; } |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Initializes a new instance of the <see cref="PluginInitializationException"/> class. |
| 33 | + /// </summary> |
| 34 | + /// <param name="message">The message that describes the error.</param> |
| 35 | + /// <param name="pluginName">The name of the plugin that failed.</param> |
| 36 | + public PluginInitializationException(string message, string pluginName) |
| 37 | + : base(message) |
| 38 | + { |
| 39 | + PluginName = pluginName; |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Initializes a new instance of the <see cref="PluginInitializationException"/> class. |
| 44 | + /// </summary> |
| 45 | + /// <param name="message">The message that describes the error.</param> |
| 46 | + /// <param name="pluginName">The name of the plugin that failed.</param> |
| 47 | + /// <param name="innerException">The exception that is the cause of the current exception.</param> |
| 48 | + public PluginInitializationException(string message, string pluginName, Exception innerException) |
| 49 | + : base(message, innerException) |
| 50 | + { |
| 51 | + PluginName = pluginName; |
| 52 | + } |
| 53 | +} |
0 commit comments